This is how you update a value at a specific cell:
- Suppose the row index of the cell is
row_idx
, and the column label is'colname'
, then you can update the cell value this way:df.at[row_idx, 'colname'] = new_value
.
Or:
- Suppose the row index of the cell is
row_idx
, and the column index iscol_idx
, then you can update the cell value this way:df.iat[row_idx, col_idx] = new_value
.
I got this idea from this post by Anna Zverkova. Thank you Anna! This is very helpful!
#pythonLast modified on 2022-09-26