Note
Pandas (20) 본문
728x90
How to compute difference of differences between consequtive numbers of a series?
# Input
ser = pd.Series([1, 3, 6, 10, 15, 21, 27, 35])
# Solution
print(ser.diff().tolist())
print(ser.diff().diff().tolist())
# output
[nan, 2.0, 3.0, 4.0, 5.0, 6.0, 6.0, 8.0]
[nan, nan, 1.0, 1.0, 1.0, 1.0, 0.0, 2.0]
'Pandas' 카테고리의 다른 글
Pandas (22) (0) | 2022.08.13 |
---|---|
Pandas (21) (0) | 2022.08.12 |
Pandas (19) (0) | 2022.08.10 |
Pandas (18) (0) | 2022.08.09 |
Pandas (17) (0) | 2022.08.08 |
Comments