assign string value to a cell in pandas
For me working nice, but here are 2 alternatives for set value by last row and column name.
First is DataFrame.loc
with specify last index value by indexing:
data11.loc[data11.index[-1], 'Items Description'] = 'Average GDP'
Or DataFrame.iloc
with -1
for get last row and Index.get_loc
for get position of column Items Description
:
data11.iloc[-1, data11.columns.get_loc('Items Description')] = 'Average GDP'
print (data11) Items Description Duration China Japan Korea0 GDP 2012-2013 40000 35000 120001 GDP 2013-2014 45000 37000 125002 Average GDP NAN 42500 36000 12250