Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty data frame concatenation in emdat_impact_yearlysum #783

Merged
merged 4 commits into from
Sep 20, 2023

Conversation

emanuel-schmid
Copy link
Collaborator

@emanuel-schmid emanuel-schmid commented Sep 11, 2023

impact_data.emdat_impact_yearlysum used to concatenate empty data frames, starting with an empty one and then iteratively adding non-empty ones. This triggers a deprecation warning in pandas >= 2.1.

Changes proposed in this PR:

  • Instead of starting with an empty DataFrame, all non-empty DatatFrames are gathered in a generator which is then concatenated at once.

This PR fixes #

PR Author Checklist

PR Reviewer Checklist

Copy link
Member

@peanutfun peanutfun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emanuel-schmid I updated the code not to use localization in the empty dataframe but to instead use DataFrame.from_records to avoid having an empty data frame at any point in time. Also, the iteration now only runs over the variable data, and not over the "static" data which can just be added in the end. The tests still run through. Please re-review and merge at your convenience 😇

@emanuel-schmid
Copy link
Collaborator Author

🤩 neat!

@emanuel-schmid emanuel-schmid merged commit 36953fc into develop Sep 20, 2023
3 checks passed
@emanuel-schmid emanuel-schmid deleted the fix/impact_data_empty_concat branch September 20, 2023 11:16
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