There is a DataFrame in which one column consists of NaN . Example:

 0 UAA 280 NaN 2 UAA 280 NaN 5 UAA 919 NaN 7 UAA 919 NaN 11 UAA 919 NaN 16 UAA 919 NaN 17 UAA 371 NaN 

There is a list of row indices in which a certain number should be added to the last column <for example, this number is 2.0 and a list of indices [2, 11, 17]. It is necessary that the output was something like this:

 0 UAA 280 NaN 2 UAA 280 2.0 5 UAA 919 NaN 7 UAA 919 NaN 11 UAA 919 2.0 16 UAA 919 NaN 17 UAA 371 2.0 

Thanks a lot for all the answers!

    1 answer 1

    To do this, use the "accessor" DataFrame.loc [] :

     In [33]: df.loc[[2, 11, 17], 'C'] = 2.0 In [34]: df Out[34]: ABC 0 UAA 280 NaN 2 UAA 280 2.0 5 UAA 919 NaN 7 UAA 919 NaN 11 UAA 919 2.0 16 UAA 919 NaN 17 UAA 371 2.0