Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Fix dataframe warning #85

Merged
merged 3 commits into from
Mar 5, 2024
Merged

Conversation

harisang
Copy link
Contributor

@harisang harisang commented Mar 5, 2024

This PR addresses issue #82

@harisang harisang requested a review from fhenneke March 5, 2024 00:49
Copy link
Contributor

@fhenneke fhenneke left a comment

Choose a reason for hiding this comment

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

Looks like it does what it is supposed to.

One thing I do not understand is if this fix is equivalent to the old behavior of concat or the new behavior? Or does it make no difference in our case?

Comment on lines +91 to +97
if not prod.empty and not barn.empty:
return pd.concat([prod, barn])
if not prod.empty:
return prod.copy()
if not barn.empty:
return barn.copy()
return pd.DataFrame()
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like it does what it is supposed to. The following looks more pythonic, but I have not tested it.

Suggested change
if not prod.empty and not barn.empty:
return pd.concat([prod, barn])
if not prod.empty:
return prod.copy()
if not barn.empty:
return barn.copy()
return pd.DataFrame()
return pd.concat(df for df in [prod, barn] if not df.empty)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah agreed but i don't feel that comfortable with all these compact pythonic ways, so if you don't mind, i want to test it as is and then we can potentially make it nicer in the future.

@harisang harisang merged commit abfc588 into main Mar 5, 2024
6 checks passed
@harisang harisang deleted the fix_dataframe_concatentation_warning branch March 5, 2024 09:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants