Pandas recalculate index after a concatenation

前端 未结 3 1708
盖世英雄少女心
盖世英雄少女心 2020-12-04 22:01

I have a problem where I produce a pandas dataframe by concatenating along the row axis (stacking vertically).

Each of the constituent dataframes has an autogenerat

3条回答
  •  不知归路
    2020-12-04 22:35

    If your index is autogenerated and you don't want to keep it, you can use the ignore_index option. `

    train_df = pd.concat(train_class_df_list, ignore_index=True)
    

    This will autogenerate a new index for you, and my guess is that this is exactly what you are after.

提交回复
热议问题