Skip to content

Commit

Permalink
Changing oecd_data.py ready for more automation
Browse files Browse the repository at this point in the history
  • Loading branch information
dean-breed committed Jun 20, 2022
1 parent e9f6b25 commit 808d99a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions data_updates/Python/oecd_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
import os
import pandas as pd
import sys
from data_updates.utils import push_folder_to_github


Expand Down Expand Up @@ -73,13 +74,18 @@

recip_data = recip_data.append(pd.DataFrame(data = total_data),ignore_index=True)

max_year = recip_data["Year"].max()

recip_data = recip_data.pivot_table(index=['Donor Name', 'Purpose Name','Recipient Name'], columns='Year', values='USD Disbursement Deflated').reset_index()

cols_to_check = [2016,2017,2018,2019,2020]
cols_to_check = list(range(max_year-4,max_year+1))

recip_data[cols_to_check] = recip_data[cols_to_check].fillna(0)

recip_data["Removal"] = (recip_data[2016]==0) & (recip_data[2017]==0) & (recip_data[2018]==0) & (recip_data[2019]==0)&(recip_data[2020]==0)
recip_data["Removal"] = [True]*len(recip_data.index)

for col in cols_to_check:
recip_data.loc[recip_data[col]!=0,"Removal"] = False

recip_data = recip_data[recip_data["Removal"]==False]

Expand Down

0 comments on commit 808d99a

Please sign in to comment.