,然后对分组之后的数据框使用idxmax函数取出Count最大值所在的列,再用iloc位置索引将行取出。....agg({'pred_class': [', '.join],'pred': lambda x: list(x),
'id_part': 'first'}).reset_index()
4.删除包含特定字符串所在的行...df.groupby('name').apply(lambda x: x.sort_values('score', ascending=False)).reset_index(drop=True)
6.选择特定类型的列...df = df.apply(pd.to_numeric, errors='coerce').fillna(0)
8.优化 DataFrame 对内存的占用
方法一:只读取切实所需的列,使用usecols...df = pd.DataFrame({'列1':['a','b','c'],'列2':[[10,20], [20,30], [30,40]]})
df
df_new = df.列2.apply(pd.Series