在 pandas 系列的索引处绘制

Plot at indexes in pandas Series

我有一个 pandas 系列,里面有一些数据:

In [117]: data1.C_TRQENG
Out[117]: 
0         Nm
1       4.85
2      5.339
3      2.552
4     -0.171
5     -0.142 
6      1.218
7     -1.133
8      2.188
9       0.88
10     4.316
11     10.06
12     8.925
13     8.262
14     7.627
...

Name: C_TRQENG, Length: 1230, dtype: object

和另一个系列,其中包含该系列中的一些最大值

In [115]: data
Out[115]: 
915     199.571429
1087    173.339207
984     114.696170
27       90.184324
82       80.805341
Name: C_TRQENG, dtype: float64

In [116]: data.index
Out[116]: Int64Index([915, 1087, 984, 27, 82], dtype='int64')

我想用 plus/minus 100 的 window 绘制这些索引处的原始数据,以便了解这些点上发生的情况。我怎样才能用 plot() 做到这一点?

使用 pandas 切片为每个索引创建一个 window,然后绘制它

nlarge = pct.nlargest(5)

for ind in nlarge.index:
    high = ind + 100 
    low = ind - 100
    window = data.C_TRQENG[low:high]
    window = window.convert_objects(convert_numeric=True)
    window.plot()