我有一个pandas-Dataframe并用于resample()计算均值(例如每日或每月均值).这是一个小例子.
import pandas as pd  
import numpy as np
dates = pd.date_range('1/1/2000', periods=100)
df = pd.DataFrame(np.random.randn(100, 1), index=dates, columns=['A'])
monthly_mean = df.resample('M', how='mean')
我现在如何绘制monthly_mean?如何设置使用我新创建的DataFrame的索引monthly_mean作为x轴?提前致谢.
我正在尝试从 Pandas 数据帧创建散点图,但我不想使用 matplotlib plt。以下是脚本
df:
group people value
   1    5    100
   2    2    90
   1    10   80
   2    20   40
   1    7    10
我想在 x 轴上创建一个带有索引的散点图,只使用熊猫数据框
df.plot.scatter(x = df.index, y = df.value)
它给了我一个错误
Int64Index([0, 1, 2, 3, 4], dtype='int64') not in index
我不想使用
plt.scatter(x = df.index, y = df.value)
如何使用熊猫数据框执行此图
如果我有一个数据框,我想在哪里创建一个列对着索引的散点图,有没有比matplotlib直接使用更简单的方法,或者从索引中创建一个列表等?像这样的东西:
df.plot.scatter(x='index', y='price')
我假设这不起作用,因为索引可能包含多个系列,而Pandas将不知道应该使用哪个,没有进一步的指示.