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

policy_data()

PolicyData

Per-policy attributes for model points.

product_spec()

ProductSpecTable

Per-product loading and rate tables.

assumption()

AssumptionTable

Lookup table of assumption keys.

assumption_tables()

AsmpByDuration

Duration-based mortality / lapse tables.

mortality_tables()

MortalityTables

Mortality tables keyed by Sex / Table.

scenarios()

Scenarios

Scenario interest-rate paths.

discount_rate()

LargePolDiscount

Premium discount by sum-assured band.

prem_waiver_cost()

PremiumWaiverCost

Premium-waiver cost lookup.

const_params()

ConstParams

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 openpyxl module used to open the workbook.

Cells Summary#

Workbook#

Opens the Excel input workbook lazily; every other cell reads from it.

input_workbook()

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()

Policy data table.

mortality_tables()

Mortality tables.

mort_table_last_ages()

First Age (the row index) at which mortality reaches 1, per column.

assumption_tables()

Assumption tables by duration.

scenarios()

Economic scenarios.

discount_rate()

Per-policy premium discount based on sum-assured bands.

prem_waiver_cost()

Premium-waiver cost lookup as a dict.

const_params()

Scalar parameters from the ConstParams named range as a dict.

Lookups#

Column lookups into the assumption and product-specification tables, keyed by the model point lookup levels.

assumption(name)

Lookup column name of the AssumptionTable range.

product_spec(name)

Lookup column name of the ProductSpecTable range.

Helpers#

Generic readers that turn a named range into a DataFrame, a dict or a keyed Series.

get_named_range_as_df(name[, index_len])

Read an Excel named range as a DataFrame.

get_named_range_as_dict(name)

Read a two-column Excel named range as a dict.

get_param_series(range_name, col_name)

Helper that reads column col_name from range_name as a Series.

Cells Descriptions#

input_workbook()[source]#

Open and return the input Excel workbook.

Loads the workbook named input_file_name from the parent directory of the model with data_only=True, so that formula cells return their last cached values.

policy_data()[source]#

Policy data table.

Returns the PolicyData named range as a DataFrame, indexed by the first column (the policy ID).

mortality_tables()[source]#

Mortality tables.

Reads the MortalityTables named range, which has a two-row header of (MortTable, Sex) and an age column, and returns a DataFrame indexed by age with a MultiIndex over 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 AsmpByDuration named range as a DataFrame, indexed by the first column (typically duration).

scenarios()[source]#

Economic scenarios.

Returns the Scenarios named range as a DataFrame, indexed by the first two columns (scenario ID and time).

discount_rate()[source]#

Per-policy premium discount based on sum-assured bands.

Reads the LargePolDiscount named range, builds the breakpoints of the sum-assured bands and returns a Series aligned with policy_data() giving the discount that applies to each policy.

prem_waiver_cost()[source]#

Premium-waiver cost lookup as a dict.

Returns the PremiumWaiverCost named range, mapping the upper bound of a policy-term band to its premium-waiver loading.

const_params()[source]#

Scalar parameters from the ConstParams named range as a dict.

assumption(name)[source]#

Lookup column name of the AssumptionTable range.

Returns a Series keyed by the lookup levels (such as Product, PolType, Gen) that are not entirely empty for column name.

product_spec(name)[source]#

Lookup column name of the ProductSpecTable range.

Returns a Series keyed by the lookup levels (such as Product, PolType, Gen) that are not entirely empty for column name.

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_name from range_name as a Series.

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 for col_name is dropped, and a partially empty level raises ValueError.