在 pandas 中应用 group by 函数后如何显示所有列
How to display all the columns after applying group by function in pandas
import pandas as pd
df = pd.read_csv('filename.csv')
df
这是我的数据
datafile
这是我用过的代码
got this result
如何在按函数应用分组后获取列 'price'
result i expect
请帮帮我..!!
谢谢。
尝试idxmin
而不是min
来定位权重最小的行:
df.loc[df.groupby(['object_name', 'type'])['weight'].idxmin()]
import pandas as pd
df = pd.read_csv('filename.csv')
df
这是我的数据 datafile
这是我用过的代码
got this result
如何在按函数应用分组后获取列 'price' result i expect
请帮帮我..!! 谢谢。
尝试idxmin
而不是min
来定位权重最小的行:
df.loc[df.groupby(['object_name', 'type'])['weight'].idxmin()]