1
をdatetimeindex:私のようにインデックスの配列を持っているパンダとして私はパンダのオブジェクトを持っている
df_days
DatetimeIndex(['2015-05-24', '2015-05-24', '2015-05-24',..., '2016-03-19',
'2016-03-19', '2016-03-20'],
dtype='datetime64[ns]', length=7224, freq=None)
type(df_days)
<class 'pandas.tseries.index.DatetimeIndex'>
:
hrIdx
(array([ 23, 47, 71, 95, 119, 143, 167, 191, 215, 239, 263,
287, 311, 335, 359, 383, 407, 431, 455, 479, 503, 527,
551, 575, 599, ...,1592], dtype=int64),)
私は次のことをしようとしています:
df_days[hrIdx] = df_days[hrIdx] + td(days=-1)
しかし、割り当て操作は失敗します。 1日の減算の右側の操作は正常に動作します。
エラーは次のとおりです。
raise TypeError("Index does not support mutable operations")
TypeError: Index does not support mutable operations
私は上記を達成しようとしているようdf_days
の特定の要素のみを変更する適切な方法は何ですか?
編集:パンダのドキュメントを参照
from datetime import timedelta as td