How to update values in a specific row in a Python Pandas DataFrame?

后端 未结 4 1311
猫巷女王i
猫巷女王i 2020-12-02 12:09

With the nice indexing methods in Pandas I have no problems extracting data in various ways. On the other hand I am still confused about how to change data in an existing Da

4条回答
  •  失恋的感觉
    2020-12-02 12:53

    Update null elements with value in the same location in other. Combines a DataFrame with other DataFrame using func to element-wise combine columns. The row and column indexes of the resulting DataFrame will be the union of the two.

    df1 = pd.DataFrame({'A': [None, 0], 'B': [None, 4]})
    df2 = pd.DataFrame({'A': [1, 1], 'B': [3, 3]})
    df1.combine_first(df2)
         A    B
    0  1.0  3.0
    1  0.0  4.0
    

    more information in this link

提交回复
热议问题