I only need code to recognize the dtype of columns as done in pandas profiling (numeric and categorical) could you please extract only that code for me from pandas profiling package code.

series = series.fillna(np.nan)

# get `infer_dtypes` (bool) from config
if config.infer_dtypes:
    # Infer variable types
    vtype = typeset.infer_type(series)
    series = typeset.cast_to_inferred(series)
else:
    # Detect variable types from pandas dataframe (df.dtypes).
    # [new dtypes, changed using `astype` function are now considered]
    vtype = typeset.detect_type(series)
1

There are 1 answers

0
fish On BEST ANSWER

According to Pandas Profiling documentation the dtype of variables are inferred using Visions library Try this sample for columns type recognition:

from visions.functional import infer_type
from visions.typesets import CompleteSet
typeset = CompleteSet()
print(infer_type(df, typeset))