Set value for particular cell in pandas DataFrame using index

后端 未结 20 1619
野趣味
野趣味 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:25

    In my example i just change it in selected cell

        for index, row in result.iterrows():
            if np.isnan(row['weight']):
                result.at[index, 'weight'] = 0.0
    

    'result' is a dataField with column 'weight'

提交回复
热议问题