散点图 pandas x 轴和 y 轴上的一个变量是数据帧索引
scatter plot pandas one variable on x axis and y axis is dataframe index
我想在 pandas 中绘制散点图,x 轴是平均值,y 轴应该是数据框的索引,但我无法继续这是我的代码我有很多错误数 .
y=list(range(len(df.index)))
df.plot(kind='scatter', x='meandf', y )
error : SyntaxError: positional argument follows keyword argument
尝试以下操作:
y=list(range(len(df.index)))
df.meandf.plot(x='meandf', y=y)
或者更简洁,因为您正在绘制 Series
:
df.meandf.plot(y=y)
如果你需要维护kind = 'scatter'
你需要传递一个数据帧:
df['y'] = y # create y column for the list you created
df.plot(x='a', y='y', kind='scatter', marker='.')
df.drop('y', axis=1, inplace=True)
我想在 pandas 中绘制散点图,x 轴是平均值,y 轴应该是数据框的索引,但我无法继续这是我的代码我有很多错误数 .
y=list(range(len(df.index)))
df.plot(kind='scatter', x='meandf', y )
error : SyntaxError: positional argument follows keyword argument
尝试以下操作:
y=list(range(len(df.index)))
df.meandf.plot(x='meandf', y=y)
或者更简洁,因为您正在绘制 Series
:
df.meandf.plot(y=y)
如果你需要维护kind = 'scatter'
你需要传递一个数据帧:
df['y'] = y # create y column for the list you created
df.plot(x='a', y='y', kind='scatter', marker='.')
df.drop('y', axis=1, inplace=True)