0

Detect outliers with boxplots and histograms

plt.figure(figsize=(15, 30)) i = 0 for col in feature_vars: i += 1 plt.subplot(9, 4, i) plt.boxplot(df[col]) plt.title('{}'.format(col), fontsize=9) plt.hist(df[col]) plt.suptitle('Detect Outliers', fontsize=16, verticalalignment='top', horizontalalignment='center', fontweight='bold') plt.savefig('charts/Detect_Outlier_Plots.png', dpi=None, facecolor='w', edgecolor='g', orientation='portrait', format=None, transparent=False, bbox_inches=None, pad_inches=0.0, metadata=None) plt.show()

Scott
  • 617
  • 1
  • 5
  • 7

1 Answers1

1

Inside the for loop, check for the dtype (datatype) of the column. Either check for 'object' and then skip, or check for is_numeric and then don't skip:

how to check the dtype of a column in python pandas

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.dtypes.html

StephanT
  • 649
  • 5
  • 12