aliyun / alibabacloud-odps-maxframe-client

Apache License 2.0
3 stars 1 forks source link

{Series, DataFrame}.pct_change result error #32

Open snowljs opened 1 week ago

snowljs commented 1 week ago

maxframe code

s = md.Series([90, 91, 85])
s.pct_change().execute()

result

0         NaN
1         NaN
2         NaN
0    0.000000
1    0.011111
2   -0.055556
0   -0.010989
1    0.000000
2   -0.065934
dtype: float64

pandas code

s1 = pd.Series([90, 91, 85])
s1.pct_change()

result

0         NaN
1    0.011111
2   -0.065934
dtype: float64
snowljs commented 1 week ago

s.pct_change(periods=2).execute()

0         NaN
1         NaN
2         NaN
0         NaN
1         NaN
2         NaN
0    0.000000
1    0.011111
2   -0.055556
dtype: float64
snowljs commented 1 week ago

s.pct_change(fill_method='ffill').execute()

0         NaN
1         NaN
2         NaN
0    0.000000
1    0.011111
2   -0.055556
0   -0.010989
1    0.000000
2   -0.065934
dtype: float64
snowljs commented 1 week ago

maxframe

df = md.DataFrame({
    'FR': [4.0405, 4.0963, 4.3149],
    'GR': [1.7246, 1.7482, 1.8519],
    'IT': [804.74, 810.01, 860.13]},
    index=['1980-01-01', '1980-02-01', '1980-03-01'])
df.pct_change().execute()
---
    FR  GR  IT
1980-01-01  NaN NaN NaN
1980-02-01  NaN NaN NaN
1980-03-01  NaN NaN NaN
1980-01-01  0.000000    0.000000    0.000000
1980-02-01  0.013810    0.013684    0.006549
1980-03-01  0.067912    0.073814    0.068830
1980-01-01  -0.013622   -0.013500   -0.006506
1980-02-01  0.000000    0.000000    0.000000
1980-03-01  0.053365    0.059318    0.061876
---

pandas

df1 = pd.DataFrame({
    'FR': [4.0405, 4.0963, 4.3149],
    'GR': [1.7246, 1.7482, 1.8519],
    'IT': [804.74, 810.01, 860.13]},
    index=['1980-01-01', '1980-02-01', '1980-03-01'])
df1.pct_change()
---
FR | GR | IT
-- | -- | --
NaN | NaN | NaN
0.013810 | 0.013684 | 0.006549
0.053365 | 0.059318 | 0.061876

---