Set value for particular cell in pandas DataFrame using index

后端 未结 20 1579
野趣味
野趣味 2020-11-22 05:45

I\'ve created a Pandas DataFrame

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

and got this

    x    y
A  NaN         


        
20条回答
  •  孤街浪徒
    2020-11-22 06:47

    Soo, your question to convert NaN at ['x',C] to value 10

    the answer is..

    df['x'].loc['C':]=10
    df
    

    alternative code is

    df.loc['C':'x']=10
    df
    

提交回复
热议问题