def df_column_dtypes(df, dtype: str=None, target: str=None, max_cardinality:
    int=10):
    """Return the columns grouped by their dtypes or for a specific dtype"""
    numeric_cols = []
    cat_cols = []
    for col in df.columns:
        if col == target:
            continue
        if df[col].dtype in (int, float) and df[col].nunique(
            ) > max_cardinality:
            numeric_cols.append(col)
        else:
            cat_cols.append(col)
    dtypes = dict(numeric=numeric_cols, categorical=cat_cols)
    return dtypes[dtype] if dtype else dtypes
