2016-09-28 85 views
0

望着lmplot documentation,它显示如何使用熊猫数据帧在Seaborn数据参数lmplot

参数:

 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的参数。如何将我的熊猫数据框转换为用于lmplot的整洁(“长形”)数据框?

目前,我正在努力做到以下几点:

sns.lmplot(customers["Length of Membership"], customers["Yearly Amount Spent"], customers) 

(Seaborn被导入为sns)。上面的python代码返回一个包含很长浮点列表的错误。

+2

看起来像第一有两个参数(x和y)预计将字符串,但你传递两个系列。试试'sns.lmplot(“会员长度”,“每年消费金额”,客户)'' –

回答

1

感谢Bob Haffner,仔细观察文档,DataFrame根本就不是问题,而是我传递的X和Y参数。

我经过串联的时候我应该已经传递字符串,因为这样:

sns.lmplot("Length of Membership", "Yearly Amount Spent", customers)