回到this question/answer,有没有办法为pandas数据帧结构完成相同的功能而不将其作为numpy数组投射?
答案 0 :(得分:3)
0 -37
1 -36
2 -19
3 -99
4 29
5 20
6 3
7 -7
8 -64
9 84
10 36
11 62
12 26
13 -76
14 55
15 -24
9 84 # I want the value as 16 instead of 9 (position of 84 in list)
17 49
18 -65
19 41
OR:
s = pd.Series([1, 1, 1, 1, 1, 2, 2, 2, 3, 4, 3, 4, 3, 4, 3, 4, 5, 5, 5])
print(s.diff()[s.diff() != 0].index.values)
输出:
[0 5 8 9 10 11 12 13 14 15 16]