小编Che*_*wis的帖子

尝试更改熊猫数据框中的单个值

我已经看到一堆标题相似的问题,但我仍然无法弄清楚。我想要做的就是用值 100 替换我的数据框中第五行和第五列中的值。我认为这可以解决问题

df.loc['cheerios','rating']= 100
Run Code Online (Sandbox Code Playgroud)

因为cheerios 是行,而 rating 是列

    name        sugar  sodium rating
0   fruit loop       x      x     x
1   trix             x      x     x
2   oreo             x      x     x
3  cocoa puff        x      x     x
4  cheerio           x      x     100
Run Code Online (Sandbox Code Playgroud)

python python-3.x pandas

5
推荐指数
1
解决办法
3570
查看次数

标签 统计

pandas ×1

python ×1

python-3.x ×1