pandas efficient dataframe set row

后端 未结 2 1368
感动是毒
感动是毒 2021-02-18 18:30

First I have the following empty DataFrame preallocated:

df=DataFrame(columns=range(10000),index=range(1000))

Then I want to update the d

2条回答
  •  长情又很酷
    2021-02-18 19:02

    df=DataFrame(columns=range(10),index=range(10))
    a = np.array( [9,9,9,9,9,9,9,9,9,9] )
    

    Update row:

    df.loc[2] = a
    

    Using Jeff's idea...

    df2 = DataFrame(data=np.random.randn(10,10), index=arange(10))
    df2.head().T
    

    I have written up a notebook answering the question: https://www.wakari.io/sharing/bundle/hrojas/pandas%20efficient%20dataframe%20set%20row

提交回复
热议问题