Pandas and Ibis API
Functions in the era_py namespace.
load_data
era_py.load_data(name, *, restore_categories=True)Load a packaged dataset by name from the shared packaged data directory.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| name | str | Dataset name, e.g. “zhang_2007_windows”. | required |
| restore_categories | bool | Restore factor columns as pandas Categorical using sidecar metadata. | True |
load_farr_rda
era_py.load_farr_rda(name, *, timeout=30.0)Load an .rda dataset named name from the farr GitHub repo and return the object.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| name | str | Dataset/object name (and file stem), e.g. “camp_scores”. | required |
| timeout | float | Requests timeout in seconds. | 30.0 |
Returns
| Name | Type | Description |
|---|---|---|
The R object stored in the .rda under key name. |
get_ff_daily_factors
era_py.get_ff_daily_factors(
dataset='F-F_Research_Data_Factors_daily',
*,
start=None,
end=None,
timeout=30.0,
)Download Ken French daily factor data as a pandas DataFrame.
get_ff_ind
era_py.get_ff_ind(ind, *, timeout=30.0)Download Fama-French SIC industry definitions as a pandas DataFrame.
get_size_rets_monthly
era_py.get_size_rets_monthly(timeout=30.0)Download Ken French monthly size-portfolio returns as a pandas DataFrame.
get_me_breakpoints
era_py.get_me_breakpoints(timeout=30.0)Download Ken French market-equity breakpoints as a pandas DataFrame.
get_trading_dates
era_py.get_trading_dates(conn)get_annc_dates
era_py.get_annc_dates(db)get_event_dates
era_py.get_event_dates(
data,
conn,
permno='permno',
event_date='event_date',
win_start=0,
win_end=0,
end_event_date=None,
)get_event_rets
era_py.get_event_rets(
data,
conn,
permno='permno',
event_date='event_date',
win_start=0,
win_end=0,
end_event_date=None,
suffix='',
data_dir=None,
)load_parquet
era_py.load_parquet(con, table, schema, data_dir=None)copy_inline
era_py.copy_inline(df, con)wrds_connect
era_py.wrds_connect(wrds_id=None, use_local=False)wrds_table
era_py.wrds_table(db, table, schema)ols_dropcollinear
era_py.ols_dropcollinear(data, formula, tol=1e-10, **fit_kwargs)Drop-in replacement for ols(data, formula, …), but with R-like rank-deficiency handling: - refits using a full-rank subset of columns - returns a normal OLSResults (so fm.model.exog works) - stores dropped terms and ‘full’ (NaN-filled) coef vectors for reporting
modelsummary
era_py.modelsummary(
models,
*,
coef_omit=None,
stars=True,
estimate=None,
statistic=True,
statistic_fmt='({std_error:.3f})',
gof_map=('nobs',),
add_rows=None,
output='dataframe',
)spline_smooth
era_py.spline_smooth(data, *, x, y, df=6, n=200)Fit a cubic regression spline y ~ s(x) and return a prediction grid for plotting.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| data | DataFrame | Input data. | required |
| x | str | Column names for x and y. | required |
| y | str | Column names for x and y. | required |
| df | int | Degrees of freedom for the spline basis (patsy cr()). | 6 |
| n | int | Number of grid points for the smooth curve. | 200 |
Returns
| Name | Type | Description |
|---|---|---|
| DataFrame with columns [x, f"{y}_smooth"] suitable for plotnine geom_line(). |
rdplot
era_py.rdplot(
data,
*,
y,
x,
cutoff,
y_label,
x_label,
degree=4,
title='RD Plot',
bins=None,
binselect='esmv',
masspoints='adjust',
use_rdrobust=True,
)