Set value for particular cell in pandas DataFrame using index

后端 未结 20 1580
野趣味
野趣味 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:33

    Update: The .set_value method is going to be deprecated. .iat/.at are good replacements, unfortunately pandas provides little documentation


    The fastest way to do this is using set_value. This method is ~100 times faster than .ix method. For example:

    df.set_value('C', 'x', 10)

提交回复
热议问题