Pandas concat failing

后端 未结 4 648
无人及你
无人及你 2020-12-03 10:24

I am trying to concat dataframes based on the foll. 2 csv files:

df_a: https://www.dropbox.com/s/slcu7o7yyottujl/df_current.csv?dl=0

df_b: https://www.dropbo

4条回答
  •  孤街浪徒
    2020-12-03 10:34

    You can get around this issue with a 'manual' concatenation, in this case your

    list_of_dfs = [df_a, df_b]
    

    And instead of running

    giant_concat_df = pd.concat(list_of_dfs,0)
    

    You can use turn all of the dataframes to a list of dictionaries and then make a new data frame from these lists (merged with chain)

    from itertools import chain
    list_of_dicts = [cur_df.T.to_dict().values() for cur_df in list_of_dfs]    
    giant_concat_df = pd.DataFrame(list(chain(*list_of_dicts)))
    

提交回复
热议问题