In a python pandas DataFrame, I would like to update the value of the index in a single row (preferably in-place as the DataFrame is quite large).
The index is DatetimeIndex and the DataFrame may contain several columns.
For instance:
In [1]: import pandas as pd
In [2]: pd.DataFrame({'DATA': [1,2,3]},
index=[pd.Timestamp(2011,10,01,00,00,00),
pd.Timestamp(2011,10,01,02,00,00),
pd.Timestamp(2011,10,01,03,00,00)])
Out[5]:
DATA
2011-10-01 00:00:00 1
2011-10-01 02:00:00 2
2011-10-01 03:00:00 3
The desired output is:
DATA
2011-10-01 01:00:00 1 <---- Index changed !!!
2011-10-01 02:00:00 2
2011-10-01 03:00:00 3
Is there a simple (and cheap) way to do this for large DataFrames ?
Assuming the location of the sample is known (for instance it is the nth row the needs to be changed) !