我有一个包含两列感兴趣的数据帧,station
和{
因此,对于dataframe中的每一行,仅当hall == A and station in [A1, A2, A3] or hall == B and station in [B1, B3, B5] or ....
时才保留它
举个例子,如果这是开始测向
Date Meal Hall Station Food
04/10 lunch de neve the grill pizza
04/10 lunch de neve the kitchen burger
04/10 lunch covel the oven hot dog
04/10 lunch covel the kitchen pasta
我只想保留the grill
给德内夫,而{
我创建了一本字典,记录了我想为每个大厅保留的电台
essential_stations =
{'HallA': [station1, station2],
'HallB': [station3, station4],
'HallC': [station5, station6],
}
但是当我执行以下操作时
summary_food_df = food_df[food_df['station'].isin(essential_stations[food_df['hall']])]
我知道错误了
'Series' objects are mutable, thus they cannot be hashed
有没有其他方法可以用字典过滤掉多余的电台?在
相关问题 更多 >
编程相关推荐