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

后端 未结 12 1990
一向
一向 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

    Here's a simple and dumb solution:

    >>> import pandas as pd
    >>> df = pd.DataFrame()
    >>> df = df.append({'foo':1, 'bar':2}, ignore_index=True)
    

提交回复
热议问题