Printing, listing and counting the numerical or categorical features in a dataset Pandas

PHOTO EMBED

Mon Sep 05 2022 09:46:40 GMT+0000 (Coordinated Universal Time)

Saved by @DataSynapse82 #python #pandas #dataset #numerical #categorical #eda

# Get the Numerical Data list to infer distribution plots

numerical = [var for var in df.columns if df[var].dtype!='O'] 
print('There are {} numerical variables\n'.format(len(numerical))) 
print('The numerical variables are :', numerical)

# Get the Categorical Data list to infer distribution plots

categorical = [var for var in df.columns if df[var].dtype =='O'] 
print('There are {} Categorical variables\n'.format(len(categorical))) 
print('The Categorical variables are :', categorical)
content_copyCOPY

Snippet to visualise numerical and categoricall features of a dataset.