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.
|
Return |
|
Reindex an assumption |
Cells Descriptions#
- pandas_to_array(df_or_series)[source]#
Return
df_or_seriesas a NumPy array or as is.If the inheriting space sets
return_array = True(the default forAssumptionsandPolicyAttrs), the input is converted viato_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
seriesto one entry per policy.Looks up the values of
seriesfor each row ofpolicy_data()using the columns identified byseries.index.names(e.g.Product,PolType,Gen), and returns a Series whose index matchespolicy_dataso 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.