Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 227cc07

Browse files
Update to IMF GFS Exp code
1 parent 3c6a3e5 commit 227cc07

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

‎DataUpdate.py‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -477,22 +477,25 @@ def IMFGFSExpenditureData():
477477
import xlsxwriter
478478
import statsmodels.api as sm
479479

480-
data = pd.read_csv('input\GFSCOFOG_02-23-2018 23-30-06-28.csv')
481-
482-
data['FuncSector'] = data[str('COFOG Function Name')] + data[str('Sector Name')]
483-
484-
480+
data = pd.read_csv('input\GFSCOFOG_02-23-2018 23-30-06-28.csv',chunksize=10000)
485481
concord_table = pd.read_excel('input\CountryConcordanceIMF.xlsx')
482+
chunk_list=[]
483+
for chunk in data:
484+
chunk['FuncSector'] = chunk[str('COFOG Function Name')] + chunk[str('Sector Name')]
485+
chunk = chunk.merge(concord_table, on="Country Name", how='left')
486+
chunk=chunk[chunk['Country name in IFs'].notnull()]
487+
chunk_list.append(chunk)
486488

489+
data=pd.concat(chunk_list)
487490

488-
data = data.merge(concord_table, on="Country Name", how='left')
489491

490492

491493
data = pd.pivot_table(data, index=["Country name in IFs", "Unit Name", 'Time Period'], values=['Value'],
492494
columns=['FuncSector'], aggfunc=[np.sum])
493495
data = pd.DataFrame(data.to_records())
494496
data.columns = [hdr.replace("('sum', 'Value',", "").replace(")", "").replace("'", "") \
495497
for hdr in data.columns]
498+
print("IMF GFS Expenditure data done")
496499
return (data)
497500

498501

‎DataforIFsFirstTimeInstallations.py‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ def install(package):
88
from pip._internal import main as pip2
99
pip2(['install', package])
1010

11-
1211
install('numpy')
1312
install('requests')
1413
install('zipfile')
@@ -35,12 +34,3 @@ def install(package):
3534
install('bs4')
3635
install('lxml')
3736

38-
import zipfile
39-
#need to download Pythonfiles.zip and place in public path
40-
#this file contains all data - so with data updates just place in folder
41-
#don't extract zip file to public
42-
#could change path below to downloads folder
43-
zip_ref = zipfile.ZipFile('C:\\Users\Public\Pythonfiles.zip', 'r')
44-
zip_ref.extractall(r'C:\Users\Public')
45-
zip_ref.close()
46-

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /