Python pandas: fill a dataframe row by row

后端 未结 4 1448
[愿得一人]
[愿得一人] 2020-12-12 12:13

The simple task of adding a row to a pandas.DataFrame object seems to be hard to accomplish. There are 3 stackoverflow questions relating to this, none of which

4条回答
  •  情话喂你
    2020-12-12 12:28

    If your input rows are lists rather than dictionaries, then the following is a simple solution:

    import pandas as pd
    list_of_lists = []
    list_of_lists.append([1,2,3])
    list_of_lists.append([4,5,6])
    
    pd.DataFrame(list_of_lists, columns=['A', 'B', 'C'])
    #    A  B  C
    # 0  1  2  3
    # 1  4  5  6
    

提交回复
热议问题