.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated_examples\annuallife\plot_pvcashflows_tradlife_a.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_generated_examples_annuallife_plot_pvcashflows_tradlife_a.py: TradLife_A: present values of cashflows ============================================= Present values of liability cashflows of a simple whole life policy projected by the :mod:`~annuallife` ``TradLife_A`` model. .. seealso:: * The :mod:`~annuallife` library .. GENERATED FROM PYTHON SOURCE LINES 11-40 .. image-sg:: /generated_examples/annuallife/images/sphx_glr_plot_pvcashflows_tradlife_a_001.png :alt: plot pvcashflows tradlife a :srcset: /generated_examples/annuallife/images/sphx_glr_plot_pvcashflows_tradlife_a_001.png :class: sphx-glr-single-img .. code-block:: Python import modelx as mx proj = mx.read_model("TradLife_A").Projection vars = ['pv_premiums', 'pv_claims_surr', 'pv_claims_death', 'pv_exps_maint', 'pv_commissions', 'pv_exps_acq'] # PolicyID 171 in simplelife corresponds to idx 170 (0-based array index) # in TradLife_A. idx = 170 for cells in vars: list(proj[idx].cells[cells](t) for t in range(50)) cfs = proj[idx].frame[vars].sort_index().dropna().droplevel(['x', 'y', 'basis']) cfs.index = cfs.index.astype(int) [proj[idx].pv_net_cf[t] for t in range(50)] ncf = proj[idx].pv_net_cf.frame.sort_index() import seaborn as sns sns.set_theme(style="darkgrid") axes = ncf.plot.line(marker='o', color='r') cfs.plot(kind='bar', stacked=True, ax=axes) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.152 seconds) .. _sphx_glr_download_generated_examples_annuallife_plot_pvcashflows_tradlife_a.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_pvcashflows_tradlife_a.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_pvcashflows_tradlife_a.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_pvcashflows_tradlife_a.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_