我有一个看起来像这样的数据框:
everything file_names searched_for_found file_id_value
0 <package_name = 'a.dtsx' a.dtsx where 0
6 'test all the things' a.dtsx where 1
12 'where' a.dtsx where 2
18 'group by eggs' a.dtsx where 3
24 'order by name' a.dtsx where 4
30 where col = 'thing' b.dtsx where 5
36 select col_1, col_2 b.dtsx where 6
42 from table b.dtsx where 7
52 id_value = '123abc' b.dtsx where 8 id_value_2 = '123'
62 'hello' b.dtsx where 9
我正在运行:
df_all_xml_mfiles_tgther = df_all_xml_mfiles.groupby(['file_names', 'searched_for_found'])['everything'].apply(' '.join).reset_index()
我收到此错误消息:
sequence item 2813: expected str instance, float found
我不确定自己做错了什么,以前有没有人遇到过?据我所知,我按分组执行的值都是字符串,不是吗?
答案 0 :(得分:1)
您可能在所有列中都包含NaN,在fillna
之前添加groupby
df_all_xml_mfiles.fillna('').groupby(['file_names', 'searched_for_found'])['everything'].apply(' '.join).reset_index()