Created
May 28, 2021 14:12
-
-
Save patrickbrus/edf0e20b88ef5b6efd8f00793cf3547f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create a list of categorical features to loop over | |
list_categorical_features = df.columns[(df.dtypes == np.object).values].to_list() | |
# create a list of numerical features to loop over | |
list_numerical_features = df.columns[np.logical_not((df.dtypes == np.object).values)].to_list() | |
# plot on histogram for each numerical feature | |
for numerical_feature in list_numerical_features: | |
plt.title(f"Histogram of {numerical_feature}") | |
plt.hist(df[numerical_feature]) | |
plt.show() | |
# call value_counts for each categorical feature | |
for cat_feature in list_categorical_features: | |
print(df[cat_feature].value_counts()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment