Pandas concat flips all my values in the DataFrame

后端 未结 3 1283
北恋
北恋 2021-01-29 06:31

I have a dataframe called \'running_tally\'

        list   jan_to  jan_from
0         LA    True      False
1         NY   False       True

I am

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-29 06:49

    I am not sure why you want to use a groupby in this case... when using concat there is no need to specify which columns you want to use, as long as their names are identical. Simple concatenation like this should do:

    running_tally = pd.concat([running_tally,new_data], ignore_index=True, sort=False)
    

    EDIT to take question edit into account: this should do the same job, without duplicates.

    running_tally = running_tally.merge(new_data, on="list", how="outer")
    

提交回复
热议问题