casact / chainladder-python

Actuarial reserving in Python
https://chainladder-python.readthedocs.io/en/latest/
Mozilla Public License 2.0
192 stars 71 forks source link

Support for Polars and other dataframes #482

Closed johalnes closed 11 months ago

johalnes commented 11 months ago

Overview

As discussed in #474, added Python dataframe interchange protocol.

This open up the possibility for using the chain ladder package with multiple different dataframe packages, like Spark, Polars, Vaex etc.

Behind the scene it uses the "new" pandas function pd.api.interchange.from_dataframe(data) that magically converts a dataframe to the correct types and other dataframe adjustments to make it pandas compatible.

Testing

Tested with the example from issue #474 and added test to ensure same result with polars and pandas

johalnes commented 11 months ago

I'm using Ruff for linting and formatting, which complains about some best practices not being followed. Mostly unused imports, isort complains about sorting of imports, but also that type(value) is str should be changed with is instance(value, str) according to some PEP.

Should I create a new issue and pull request with ruff as formatter and use auto fix to remove those smaller "issues"?

codecov[bot] commented 11 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (ac3fa37) 81.70% compared to head (63cea7f) 81.73%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #482 +/- ## ========================================== + Coverage 81.70% 81.73% +0.02% ========================================== Files 80 80 Lines 4712 4719 +7 Branches 806 807 +1 ========================================== + Hits 3850 3857 +7 Misses 659 659 Partials 203 203 ``` | [Flag](https://app.codecov.io/gh/casact/chainladder-python/pull/482/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=casact) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/casact/chainladder-python/pull/482/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=casact) | `81.73% <100.00%> (+0.02%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=casact#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jbogaardt commented 11 months ago

Thanks for these updates @johalnes !

jbogaardt commented 11 months ago

I'm using Ruff for linting and formatting, which complains about some best practices not being followed. Mostly unused imports, isort complains about sorting of imports, but also that type(value) is str should be changed with is instance(value, str) according to some PEP.

Should I create a new issue and pull request with ruff as formatter and use auto fix to remove those smaller "issues"?

Sure!