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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/fetch/orderbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ def get_order_rewards(cls, block_range: BlockRange) -> DataFrame:

# Solvers do not appear in both environments!
assert set(prod.solver).isdisjoint(set(barn.solver)), "solver overlap!"
return pd.concat([prod, barn])
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()
Comment on lines +91 to +97
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.


@classmethod
def get_batch_rewards(cls, block_range: BlockRange) -> DataFrame:
Expand Down Expand Up @@ -116,4 +122,10 @@ def get_batch_rewards(cls, block_range: BlockRange) -> DataFrame:

# Solvers do not appear in both environments!
assert set(prod.solver).isdisjoint(set(barn.solver)), "solver overlap!"
return pd.concat([prod, barn])
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()
Loading