【发布时间】:2017-02-05 19:51:00
【问题描述】:
查看lmplot documentation,它显示
参数:
x, y : strings, optional Input variables; these should be column names in data. data : DataFrame Tidy (“long-form”) dataframe where each column is a variable and each row is an observation.
我有一个熊猫数据框customers,我想将它用作lmplot 的参数。如何将我的 pandas 数据框转换为整洁(“长格式”)数据框以用于lmplot?
目前,我正在尝试执行以下操作:
sns.lmplot(customers["Length of Membership"], customers["Yearly Amount Spent"], customers)
(Seaborn 被导入为sns)。上面的 python 代码返回一个错误,其中包含很长的浮点列表。
【问题讨论】:
-
看起来前两个参数(x 和 y)应该是字符串,但是你传递了两个系列。试试
sns.lmplot("Length of Membership", "Yearly Amount Spent", customers)
标签: python pandas dataframe seaborn