df:
make country other_columns sale
honda tokyo data 1
honda hirosima data 0
toyota tokyo data 1
toyota hirosima data 0
suzuki tokyo data 0
suzuki hirosima data 0
ferrari tokyo data 1
ferrari hirosima data 0
nissan tokyo data 1
nissan hirosima data 0
条件:保持具有1,0的货币对
期望的输出
make country other_columns sale
honda tokyo data 1
honda hirosima data 0
toyota tokyo data 1
toyota hirosima data 0
ferrari tokyo data 1
ferrari hirosima data 0
nissan tokyo data 1
nissan hirosima data 0
我尝试了什么(这显然不起作用)
outdf = df.groupby('sale').filter(lambda x: x > 0)
我应该将两个列都分组吗(“ sale”和“ make”)?
慕无忌1623718
相关分类