Skip to content

Commit

Permalink
Make compatible with pandas==2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 committed Apr 14, 2023
1 parent e4f29a1 commit 4f551f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions process_oni.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# cumulatively count how many months stay in same threshold before changing
df['threshold_group'] = (df['threshold'] != df['threshold'].shift(1)).cumsum()
df['cumulative'] = df.groupby('threshold_group')['anom_c'].apply(
df['cumulative'] = df.groupby('threshold_group', group_keys=False)['anom_c'].apply(
lambda col: (col ** 0).cumsum()).astype(int)

# classify it's a warm (el nino) or cold period (la_nina) based on
Expand All @@ -29,7 +29,7 @@
df.to_csv('oni.csv', index=False)

# mimic the format of https://origin.cpc.ncep.noaa.gov/products/analysis_monitoring/ensostuff/ONI_v5.php
pivot_df = df[['season', 'year', 'oni']].pivot('year', 'season', 'oni')
pivot_df = df[['season', 'year', 'oni']].pivot(index='year', columns='season', values='oni')
pivot_df = pivot_df[['DJF', 'JFM', 'FMA', 'MAM', 'AMJ', 'MJJ',
'JJA', 'JAS', 'ASO', 'SON', 'OND', 'NDJ']]
pivot_df.to_csv('oni_cpc_table.csv')

0 comments on commit 4f551f1

Please sign in to comment.