Skip to content

Support for Polars and other dataframes#482

Merged
jbogaardt merged 4 commits intocasact:masterfrom
johalnes:feature/474_interchange_api
Dec 15, 2023
Merged

Support for Polars and other dataframes#482
jbogaardt merged 4 commits intocasact:masterfrom
johalnes:feature/474_interchange_api

Conversation

@johalnes
Copy link
Copy Markdown
Contributor

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
Copy link
Copy Markdown
Contributor Author

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
Copy link
Copy Markdown

codecov bot commented Dec 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@            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 Coverage Δ
unittests 81.73% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jbogaardt jbogaardt merged commit e5ceaf6 into casact:master Dec 15, 2023
@jbogaardt
Copy link
Copy Markdown
Collaborator

Thanks for these updates @johalnes !

@jbogaardt
Copy link
Copy Markdown
Collaborator

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!

@johalnes johalnes deleted the feature/474_interchange_api branch December 16, 2023 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants