Set value for particular cell in pandas DataFrame using index

I have created a Pandas DataFrame

df = DataFrame(index=['A','B','C'], columns=['x','y'])

Now, I would like to assign a value to particular cell, for example to row C and column x. In other words, I would like to perform the following transformation:

     x    y             x    y
A  NaN  NaN        A  NaN  NaN
B  NaN  NaN   ⟶   B  NaN  NaN
C  NaN  NaN        C   10  NaN

with this code:

df.xs('C')['x'] = 10

However, the contents of df has not changed. The dataframe contains yet again only NaNs. How do I what I want?

← Назад к списку