Skip to content

FIX: FutureWarning in heavy_tails #581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions lectures/heavy_tails.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jupytext:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.16.1
jupytext_version: 1.16.7
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand All @@ -19,7 +19,7 @@ In addition to what's in Anaconda, this lecture will need the following librarie
```{code-cell} ipython3
:tags: [hide-output]

!pip install --upgrade yfinance pandas_datareader
!pip install --upgrade yfinance wbgapi
```

We use the following imports.
Expand All @@ -31,7 +31,7 @@ import yfinance as yf
import pandas as pd
import statsmodels.api as sm

from pandas_datareader import wb
import wbgapi as wb
from scipy.stats import norm, cauchy
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()
Expand Down Expand Up @@ -790,24 +790,21 @@ def empirical_ccdf(data,
:tags: [hide-input]

def extract_wb(varlist=['NY.GDP.MKTP.CD'],
c='all_countries',
c='all',
s=1900,
e=2021,
varnames=None):
if c == "all_countries":
# Keep countries only (no aggregated regions)
countries = wb.get_countries()
countries_name = countries[countries['region'] != 'Aggregates']['name'].values
c = "all"

df = wb.download(indicator=varlist, country=c, start=s, end=e).stack().unstack(0).reset_index()
df = df.drop(['level_1'], axis=1).transpose()
df = wb.data.DataFrame(varlist, economy=c, time=range(s, e+1, 1), skipAggs=True)
df.index.name = 'country'

if varnames is not None:
df.columns = varnames
df = df[1:]
df.columns = variable_names

cntry_mapper = pd.DataFrame(wb.economy.info().items)[['id','value']].set_index('id').to_dict()['value']
df.index = df.index.map(lambda x: cntry_mapper[x]) #map iso3c to name values

df1 =df[df.index.isin(countries_name)]
return df1
return df
```

### Firm size
Expand Down Expand Up @@ -914,9 +911,9 @@ variable_code = ['NY.GDP.MKTP.CD', 'NY.GDP.PCAP.CD']
variable_names = ['GDP', 'GDP per capita']

df_gdp1 = extract_wb(varlist=variable_code,
c="all_countries",
s="2021",
e="2021",
c="all",
s=2021,
e=2021,
varnames=variable_names)
df_gdp1.dropna(inplace=True)
```
Expand Down
Loading