Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/updates_for_ogcore' into updates…
Browse files Browse the repository at this point in the history
…_for_ogcore
  • Loading branch information
jdebacker committed May 17, 2024
2 parents f27dde1 + bf76bd6 commit 5ddb060
Showing 1 changed file with 39 additions and 41 deletions.
80 changes: 39 additions & 41 deletions ogzaf/macro_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,34 +83,32 @@ def get_macro_params():
wb_data_q = wb_data_q.set_index("year")

"""
This retrieves labour share data from the United Nations Data Portal API
(see https://data.un.org)
This retrieves labour share data from the ILOSTAT Data API
(see https://rshiny.ilo.org/dataexplorer9/?lang=en)
"""

# target = (
# "https://data.un.org/ws/rest/data/IAEG-SDGs,DF_SDG_GLH/"
# + "..SL_EMP_GTOTL.710..........."
# + "?startPeriod="
# + str(start.year)
# + "&"
# + "endPeriod="
# + str(end.year)
# + "&format=csv"
# )

# response = get_legacy_session().get(target)
# print("TaRGET = ", target)
target = (
"https://rplumber.ilo.org/data/indicator/"
+ "?id=LAP_2GDP_NOC_RT_A"
+ "&ref_area="
+ str(country_iso)
+ "&timefrom="
+ str(start.year)
+ "&timeto="
+ str(end.year)
+ "&type=both&format=.csv"
)

# # Check if the request was successful before processing
# if response.status_code == 200:
# csv_content = StringIO(response.text)
# df_temp = pd.read_csv(csv_content)
# else:
# print(
# f"Failed to retrieve data. HTTP status code: {response.status_code}"
# )
response = requests.get(target)
if response.status_code == 200:
csv_content = StringIO(response.text)
df_temp = pd.read_csv(csv_content)
else:
print(
f"Failed to retrieve data. HTTP status code: {response.status_code}"
)

# un_data_a = df_temp[["TIME_PERIOD", "OBS_VALUE"]]
ilo_data = df_temp[["time", "obs_value"]]

"""
This retrieves data from FRED.
Expand All @@ -127,11 +125,11 @@ def get_macro_params():
}

# pull series of interest using pandas_datareader
fred_data = web.DataReader(fred_variable_dict.values(), "fred", start, end)
fred_data.rename(
columns=dict((y, x) for x, y in fred_variable_dict.items()),
inplace=True,
)
# fred_data = web.DataReader(fred_variable_dict.values(), "fred", start, end)
# fred_data.rename(
# columns=dict((y, x) for x, y in fred_variable_dict.items()),
# inplace=True,
# )

# Separate quartely, monthly, and annual FRED dataseries

Expand Down Expand Up @@ -195,19 +193,19 @@ def get_macro_params():

# find gamma
macro_parameters["gamma"] = [
# 1
# - (
# (
# un_data_a.loc[
# un_data_a["TIME_PERIOD"] == baseline_date.year, "OBS_VALUE"
# ].squeeze()
# )
# / 100
# )
1
- pd.Series(
(fred_data["Labor share of income"]).loc[baseline_yearquarter]
).mean()
- (
(
ilo_data.loc[
ilo_data["time"] == baseline_date.year, "obs_value"
].squeeze()
)
/ 100
)
# 1
# - pd.Series(
# (fred_data["Labor share of income"]).loc[baseline_yearquarter]
# ).mean()
]

# find g_y
Expand Down

0 comments on commit 5ddb060

Please sign in to comment.