Lets say I want to set a columns value in a DataFrame
.
- It works when I do have standard integer indexes:
df.loc[14:, 'avg_gain'] = 5
but when I have a DatetimeIndex
:
df.set_index(keys=['ts'], inplace=True)
(or another Index, which is non-integer), it yields
TypeError: cannot do slice indexing on <class 'pandas.core.indexes.datetimes.DatetimeIndex'> with these indexers [14] of <class 'int'>
)
So how is it possible to skip the first x
rows when applying new values on a DataFrame
which has an alternative index than the standard one?