简体   繁体   中英

Python pandas - broken groupby and ordering after upgrade to 1.1.0

I have a code that was/is working fine up to python pandas 1.0.5:

av_mixes = pd.merge(mix[~(mix['UsedUp'])].reset_index(drop=False),
                    consumption, how='left', left_on='index',
                    right_on='ID').groupby(['index'])['Consumed'].max()

where mix and consumption are pandas DataFrames, and the mix['UsedUp'] column is boolean, the mix['index'] and consumption['ID'] columns are numbers and mix['Consumed'] is DateTime.

The role of this is to collect the mixes which are not yet used up, match them with their consumption records, and give for each remaining mix the most recent time when its consumption was recorded. And this worked quite fine until the new update. Since then, I get the following error debug message:

python pandas error "assert values.dtype == "i8""

and I get an AssertionError .

I have checked the release notes for Pandas 1.1.0 and there seems to be some change related to both grouping and timestamps, but I don't see how any of those changes would affect my use case.

Thank you for advance.

UPDATE : It seems to me that some recent updates to other packages (pandas is 1.1.0 on my system now) solved the issue, so some other python packages might have been the culprit.

it is a problem of release for Pandas 1.1.0 Solution - downgrade to version 1.0.3 (0.24.1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM