The Utilities Space#

Helper cells shared by Assumptions and PolicyAttrs.

This Space is used as a base Space (_bases) for Assumptions and PolicyAttrs, which both derive their per-policy values by mapping pandas tables onto the rows of the policy data.

The cells in this Space rely on a return_array reference, which is defined by the inheriting space (True to convert results to NumPy arrays, False to keep them as pandas objects).

Cells Summary#

Helpers that convert pandas objects to per-policy NumPy arrays and reindex assumption tables onto the policy data.

pandas_to_array(df_or_series)

Return df_or_series as a NumPy array or as is.

map_to_policies(series)

Reindex an assumption series to one entry per policy.

Cells Descriptions#

pandas_to_array(df_or_series)[source]#

Return df_or_series as a NumPy array or as is.

If the inheriting space sets return_array = True (the default for Assumptions and PolicyAttrs), the input is converted via to_numpy(). Otherwise the original pandas object is returned unchanged.

This is an uncached cell, so it is recomputed on every call.

map_to_policies(series)[source]#

Reindex an assumption series to one entry per policy.

Looks up the values of series for each row of policy_data() using the columns identified by series.index.names (e.g. Product, PolType, Gen), and returns a Series whose index matches policy_data so it aligns with the per-policy NumPy arrays used elsewhere in the model.

This is an uncached cell, so it is recomputed on every call.