-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Description
Pandas version checks
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
# 示例数据
df = pd.DataFrame({
'product_code': ['X', 'X', 'X', 'Y', 'Y'],
'units': ['P', 'P', 'Q', 'Q', 'Q']
})
df2 = df.head(2)
df2 = df2.sort_values('product_code', ascending=False)\
.groupby(['product_code',
'unit_name'])\
.first().reset_index(drop=True)
print(df2)
Issue Description
When there are only 2 lines of data in df, this code will run successfully, even if the fields do not exist. We have not found this situation in other rows so far
Expected Behavior
It exists in version 2.2.2 of pandas。
Installed Versions
Replace this line with the output of pd.show_versions()