Set value for particular cell in pandas DataFrame using index

后端 未结 20 1874
野趣味
野趣味 2020-11-22 05:45

I\'ve created a Pandas DataFrame

df = DataFrame(index=[\'A\',\'B\',\'C\'], columns=[\'x\',\'y\'])

and got this

    x    y
A  NaN         


        
20条回答
  •  滥情空心
    2020-11-22 06:25

    If you want to change values not for whole row, but only for some columns:

    x = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
    x.iloc[1] = dict(A=10, B=-10)
    

提交回复
热议问题