小编jka*_*.ne的帖子

熊猫系列的循环移位

我在pandas (文档)中使用shift方法处理数据系列 .

是否可以在一个步骤中进行循环移位,即第一个值成为最后一个值?

>>> input
Out[20]: 
5     0.995232
15    0.999794
25    1.006853
35    0.997781
45    0.981553
Name: vRatio, dtype: float64

>>> input.shift()
Out[21]: 
5          NaN
15    0.995232
25    0.999794
35    1.006853
45    0.997781
Name: vRatio, dtype: float64
Run Code Online (Sandbox Code Playgroud)

期望的输出:

Out[21]: 
5     0.981553
15    0.995232
25    0.999794
35    1.006853
45    0.997781
Name: vRatio, dtype: float64
Run Code Online (Sandbox Code Playgroud)

python pandas

8
推荐指数
1
解决办法
3290
查看次数

标签 统计

pandas ×1

python ×1