Append an empty row in dataframe using pandas

前端 未结 8 2021
忘了有多久
忘了有多久 2021-02-01 13:25

I am trying to append an empty row at the end of dataframe but unable to do so, even trying to understand how pandas work with append function and still not getting it.

8条回答
  •  忘掉有多难
    2021-02-01 14:00

    Add a new pandas.Series using pandas.DataFrame.append().

    If you wish to specify the name (AKA the "index") of the new row, use:

    df.append(pandas.Series(name='NameOfNewRow'))
    

    If you don't wish to name the new row, use:

    df.append(pandas.Series(), ignore_index=True)
    

    where df is your pandas.DataFrame.

提交回复
热议问题