2
我遍歷一個數據幀中的每一列,並試圖創建日誌地塊作爲Matplotlib:廣東話創建日誌地塊
cols = in_df.columns
for col in cols:
in_df[col]=in_df[col].dropna()
print (in_df[col].values)
in_df[col].map(np.log).hist(bins=1000)
plt.xlabel(x_label+col)
plt.ylabel('Number of customers in train')
plt.savefig(save_dir+col+'.png')
plt.close()
,但我得到
[2 2 2 ..., 2 2 2]
in_df[col].map(np.log).hist(bins=1000)
File "anaconda/envs/kaggle3/lib/python3.5/site-packages/pandas/tools/plotting.py", line 2988, in hist_series
ax.hist(values, bins=bins, **kwds)
File "anaconda/envs/kaggle3/lib/python3.5/site-packages/matplotlib/__init__.py", line 1819, in inner
return func(ax, *args, **kwargs)
File "anaconda/envs/kaggle3/lib/python3.5/site-packages/matplotlib/axes/_axes.py", line 5985, in hist
m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs)
File "anaconda/envs/kaggle3/lib/python3.5/site-packages/numpy/lib/function_base.py", line 505, in histogram
'range parameter must be finite.')
ValueError: range parameter must be finite.
注意,下面的工作
in_df.col_name.map(np.log).hist(bins=1000)
在遍歷所有列的我不能怎麼過使用這種方法。任何想法爲什麼我得到錯誤?
你正在取零的日誌? – piRSquared
嗯,沒有想到這一點。那裏可能有零點 – AbtPst