Is it possible to append Series to rows of DataFrame without making a list first?

前端 未结 6 1554
萌比男神i
萌比男神i 2021-02-01 01:07

I have some data I\'m trying to organize into a DataFrame in Pandas. I was trying to make each row a Series and append it to the Da

6条回答
  •  终归单人心
    2021-02-01 01:33

    This would work as well:

    df = pd.DataFrame()
    new_line = pd.Series({'A2M': 4.059, 'A2ML1': 4.28}, name='HCC1419')
    df = df.append(new_line, ignore_index=False)
    

    The name in the Series will be the index in the dataframe. ignore_index=False is the important flag in this case.

提交回复
热议问题