【发布时间】:2020-08-13 05:38:44
【问题描述】:
for feature in features_with_na:
data = train.copy()
# make a variable that indicates 1 if the observation was missing or 0 if not missing
data[feature] = np.where(data[feature].isnull(), 1, 0)
# calculate median sales price where the information is missing or present
data.groupby(feature)['saleprice'].median().plot.bar()
plt.title(feature)
plt.show()
我运行此代码是为了查看我的 pandas 数据框中各列之间的关系以及销售价格(恰好是其中一列)。我想通过将我的缺失值转换为 1 来寻找销售价格和列中缺失值之间的某种形式的关系,如果它不是缺失值,则为 0。但是,我得到了很多情节,我必须滚动一个单独的单元格,这使得它变得非常困难。是否有代码可以让我防止滚动特定的内容,以便我一次看到所有的图?
【问题讨论】:
标签: python pandas matplotlib data-science