【发布时间】:2018-06-09 11:38:03
【问题描述】:
所以我正在尝试使用 for 循环为我的 DatFrame 中的所有连续变量绘制直方图
df1 = df.select_dtypes([np.object])
for i, col in enumerate(df1.columns):
plt.figure(i)
sns.countplot(x=col, data=df1)
我在这里通过搜索找到的。
但是现在我想对 distplot 做同样的事情,所以我尝试将上面的代码修改为:
df1 = dftest.select_dtypes([np.int, np.float])
for i, col in enumerate(df1.columns):
plt.figure(i)
sns.distplot(df1)
但它只是给了我一个空的情节。关于我能做什么的任何想法?
编辑:例如DataFrame:
dftest = pd.DataFrame(np.random.randint(low=0, high=10, size=(5, 5)),
columns=['a', 'b', 'c', 'd', 'e'])
【问题讨论】:
-
您好像忘记在此处提供minimal reproducible example。
-
我的错,添加了编辑以便重现
标签: python pandas plot seaborn