Appending a list or series to a pandas DataFrame as a row?

后端 未结 12 1982
一向
一向 2020-12-02 05:22

So I have initialized an empty pandas DataFrame and I would like to iteratively append lists (or Series) as rows in this DataFrame. What is the best way of doing this?

12条回答
  •  粉色の甜心
    2020-12-02 05:43

    simply use loc:

    >>> df
         A  B  C
    one  1  2  3
    >>> df.loc["two"] = [4,5,6]
    >>> df
         A  B  C
    one  1  2  3
    two  4  5  6
    

提交回复
热议问题