The InputData Space#
Input data loaded from input.xlsx.
The InputData Space contains Cells that
load values from named ranges in the Excel input file, input.xlsx,
and helper Cells that turn those ranges into pandas objects ready for
the rest of the model.
Per-policy attributes, assumption tables, scenarios, mortality tables
and product specs are loaded on demand by the cells listed below. The
workbook itself is opened lazily by input_workbook().
The table below lists the cells and the Excel named ranges they read.
Cell |
Named range |
Purpose |
|---|---|---|
|
Per-policy attributes for model points. |
|
|
Per-product loading and rate tables. |
|
|
Lookup table of assumption keys. |
|
|
Duration-based mortality / lapse tables. |
|
|
Mortality tables keyed by Sex / Table. |
|
|
Scenario interest-rate paths. |
|
|
Premium discount by sum-assured band. |
|
|
Premium-waiver cost lookup. |
|
|
Scalar parameters used across the model. |
Parameters and References#
- input_file_name#
Name of the Excel workbook to read. Defaults to
"input.xlsx"and is resolved relative to the parent directory of the model.- Type:
str
- openpyxl#
The
openpyxlmodule used to open the workbook.
Cells Summary#
Workbook#
Opens the Excel input workbook lazily; every other cell reads from it.
Open and return the input Excel workbook. |
Input Tables#
Named ranges loaded as pandas objects: policy data, mortality and assumption tables, scenarios, discount and premium-waiver lookups and the scalar constants.
Policy data table. |
|
Mortality tables. |
|
First Age (the row index) at which mortality reaches 1, per column. |
|
Assumption tables by duration. |
|
Economic scenarios. |
|
Per-policy premium discount based on sum-assured bands. |
|
Premium-waiver cost lookup as a |
|
Scalar parameters from the |
Lookups#
Column lookups into the assumption and product-specification tables, keyed by the model point lookup levels.
|
Lookup column |
|
Lookup column |
Helpers#
Generic readers that turn a named range into a DataFrame, a
dict or a keyed Series.
|
Read an Excel named range as a |
|
Read a two-column Excel named range as a |
|
Helper that reads column |
Cells Descriptions#
- input_workbook()[source]#
Open and return the input Excel workbook.
Loads the workbook named
input_file_namefrom the parent directory of the model withdata_only=True, so that formula cells return their last cached values.
- policy_data()[source]#
Policy data table.
Returns the
PolicyDatanamed range as aDataFrame, indexed by the first column (the policy ID).
- mortality_tables()[source]#
Mortality tables.
Reads the
MortalityTablesnamed range, which has a two-row header of(MortTable, Sex)and an age column, and returns aDataFrameindexed by age with aMultiIndexover the columns.
- mort_table_last_ages()[source]#
First Age (the row index) at which mortality reaches 1, per column.
Returns a Series indexed by
mortality_tables().columns(a MultiIndex of (MortTable, Sex)) with the Age value from the row index.
- assumption_tables()[source]#
Assumption tables by duration.
Returns the
AsmpByDurationnamed range as aDataFrame, indexed by the first column (typically duration).
- scenarios()[source]#
Economic scenarios.
Returns the
Scenariosnamed range as aDataFrame, indexed by the first two columns (scenario ID and time).
- discount_rate()[source]#
Per-policy premium discount based on sum-assured bands.
Reads the
LargePolDiscountnamed range, builds the breakpoints of the sum-assured bands and returns aSeriesaligned withpolicy_data()giving the discount that applies to each policy.
- prem_waiver_cost()[source]#
Premium-waiver cost lookup as a
dict.Returns the
PremiumWaiverCostnamed range, mapping the upper bound of a policy-term band to its premium-waiver loading.
- assumption(name)[source]#
Lookup column
nameof theAssumptionTablerange.Returns a
Serieskeyed by the lookup levels (such asProduct,PolType,Gen) that are not entirely empty for columnname.
- product_spec(name)[source]#
Lookup column
nameof theProductSpecTablerange.Returns a
Serieskeyed by the lookup levels (such asProduct,PolType,Gen) that are not entirely empty for columnname.
- get_named_range_as_df(name, index_len=0)[source]#
Read an Excel named range as a
DataFrame.- Parameters:
name (
str) – The Excel defined-name to read.index_len (
int, optional) – Number of leading columns to use as the DataFrame index. Defaults to 0 (no index column).
- get_named_range_as_dict(name)[source]#
Read a two-column Excel named range as a
dict.The first column of the range becomes the dict keys and the second column becomes the values.
- get_param_series(range_name, col_name)[source]#
Helper that reads column
col_namefromrange_nameas aSeries.The named range is loaded via
get_named_range_as_df()with the first three columns used as a MultiIndex. Any index level that is entirely empty forcol_nameis dropped, and a partially empty level raisesValueError.