【发布时间】:2021-02-27 14:35:46
【问题描述】:
所以我一直在尝试将数据分配到 bin 中,然后对其使用 countplot 函数。但这给了我一个错误。代码的分箱部分似乎工作正常,问题可能出在 countplot 函数上。如果您能建议如何更正以下内容,那就太好了。 ps:这可能看起来微不足道,但我是数据科学的新手。
binned=pd.cut(lab3['Survived'],[0,10,20,30,40,50,60,70,80])
p = sns.countplot(x='Survived',data=binned, hue='Survived')
错误:
ValueError Traceback (most recent call last)
<ipython-input-41-67a29c8aa363> in <module>()
1 labels = [0-10,11-20]
2 binned=pd.cut(lab3['Survived'],[0,10,20,30,40,50,60,70,80])
----> 3 p = sns.countplot(x='Survived',data=binned, hue='Survived')
3 frames
/usr/local/lib/python3.6/dist-packages/seaborn/categorical.py in establish_variables(self, x, y, hue, data, orient, order, hue_order, units)
151 if isinstance(var, str):
152 err = "Could not interpret input '{}'".format(var)
--> 153 raise ValueError(err)
154
155 # Figure out the plotting orientation
ValueError: Could not interpret input 'Survived'
【问题讨论】:
标签: python pandas seaborn data-science