First, I create a pandas dataframe from a .csv file:
df1 = pd.read_csv(infile1, sep=",", usecols=cols, header=0, names=["Timestamp","x"])
Second, I do print df1.head()
which produces:
Timestamp x
0 1491894899989 15424
1 1491894899984 15424
2 1491894899979 15488
3 1491894899974 15488
4 1491894899969 15488
Then, doing print int(df1.x.iloc[[0]].values)
yields 15424
.
Now, I want to replace the iloc[[0]]
value for x
.
The line df1.x.iloc[[0]].values == 88
does not do the trick, since print int(df1.x.iloc[[0]].values)
still yields 15424
rather than 88
.
How to replace the value in the nth row of a given column in a pandas dataframe?