【发布时间】:2019-02-15 11:33:17
【问题描述】:
我目前正在尝试开发一个便利功能,它应该为 pandas 数据框中的每一列创建一个基本图,其中包含数据框中所有列的数据集中的值及其数量。
def plot_value_counts(df, leave_out):
# is supposed to create the subplots grid where I can add the plots
fig, axs = plt.subplots(int(len(df)/2) + 1,int(len(df)/2) + 1)
for idx, name in enumerate(list(df)):
if name == leave_out:
continue
else:
axs[idx] = df[name].value_counts().plot(kind="bar")
return fig, axs
这个 sn-p 永远运行,永不停止。 我尝试查看有关 stackoverflow 的其他类似问题,但找不到任何针对我的案例的具体问题。
subplots函数的用法来自以下问题:Is it possible to automatically generate multiple subplots in matplotlib?
下面是一个简短的数据文件示例,以便大家理解问题: https://gist.github.com/hentschelpatrick/e0a7e1400a4b5c356ec8b0e4952f8cc1#file-train-csv
【问题讨论】:
-
您能否提供一个(简短的!)输入示例,该过程为您挂起?
-
@asongtoruin 我用一些数据添加了一个指向要点的链接。
标签: python pandas matplotlib