python: best way convey missing value count -
i have data frame 9 features , features have missing values. following count
of missing values in each feature:
df.isnull().sum()
which gives me:
a 0 b 0 c 15844523 d 717 e 18084 f 118679 g 0 h 978505 0
i want display information in nice way. can create table in report there other way display in plot?
i think can use numpy.log
series.plot.bar
:
import matplotlib.pyplot plt np.log(s).plot.bar() plt.show()
another solution categorize data bins cut
, use series.plot.bar
:
import matplotlib.pyplot plt #convert series 1 column df column name 'name' df = s.rename('name').to_frame() bins = [-1,1, 10, 100, 1000,10000,100000,1000000,10000000, 100000000,np.inf] labels=[0,1,2,3,4,5,6,7,8,9] df['label'] = pd.cut(df['name'], bins=bins, labels=labels) print (df.label) 0 b 0 c 8 d 3 e 5 f 6 g 0 h 6 0 name: label, dtype: category categories (10, int64): [0 < 1 < 2 < 3 ... 6 < 7 < 8 < 9] df.label.astype(int).plot.bar() plt.show()
i think nicer plot column name
:
df.name.plot.bar() plt.show()
Comments
Post a Comment