![](/img/trans.png)
[英]Set value for particular cell in pandas DataFrame with iloc
[英]Set value for particular cell in pandas DataFrame
這個問題類似於這個問題早些時候公布。 區別在於我要更改索引列不是唯一的單元格中的值。 例如:
x y
A 1 5
B 4 6
C 0 3
C 5 9
我想用100代替9並得到:
x y
A 1 5
B 4 6
C 0 3
C 5 100
有什么建議么?
您可以使用如下順序索引(它們始終是唯一的):
In [13]: df.iloc[3, 1] = 100
In [14]: df
Out[14]:
x y
A 1 5
B 4 6
C 0 3
C 5 100
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.