-
Notifications
You must be signed in to change notification settings - Fork 34
Incompatible Pandas column selection syntax in HourlyStats(breaks with recent Pandas versions) #127
Copy link
Copy link
Open
Description
Bug Description
Running the current version of Cell2Fire(0.2) with Python (3.11.10) and pandas=2.2.3 on MacOS 15.4 results in a ValueError during statistics generation. The error is due to outdated column selection syntax inside cell2fire/utils/Stats.py
Error message
ValueError: Cannot subset columns with a tuple with more than one element. Use a list instead.
Location in the Code
all places in the Stats.py where groupby appears
Cell2Fire/cell2fire/utils/Stats.py
Line 1204 in 544c83c
| SummaryDF = Ah[["NonBurned", "Burned", "Harvested", "Hour"]].groupby('Hour')["NonBurned", "Burned", "Harvested"].mean() |
Cause of Bug
The line uses a legacy style of selecting multiple columns after groupby, passing a tuple instead of a list:
.groupby('Hour')["NonBurned", "Burned", "Harvested"]This syntex is no longer supported in newer version of Pandas. Check for example this StackOverflow post
It now requires passing a list of column names
.groupby('Hour')[["NonBurned", "Burned", "Harvested"]]Suggested FIx
- either change lines where
groupby()is used to the syntax that uses double brackets like
.groupby('Hour')[["NonBurned", "Burned", "Harvested"]]- Or Fix pandas version to
pandas<2.0.0in therequirements.txt
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels