pandasのdataframeにある時系列データから、連続した複数行を削除したいのですが、思うようにコードが書けない状況です。どなたか教えてください。よろしくお願いします。
sidx='2017-11-01 12:00:00' eidx='2017-11-02 21:00:00' df.drop(df.loc[sidx:eidx])
dataframeのデータ構造は以下の通りです。
日時
2017-10-22 12:00:00 141.90
2017-10-22 12:01:00 142.00
2017-10-22 12:02:00 142.00
2017-10-22 12:03:00 142.00
2017-10-22 12:04:00 141.95
.
.
2017-12-02 11:30:00 142.10
2017-12-02 11:31:00 142.10
2017-12-02 11:32:00 142.05
2017-12-02 11:33:00 142.05
2017-12-02 11:34:00 142.10
Freq: 60S, Name: データ, Length: 14400, dtype: float64
type(df.index)
<pandas.core.indexes.datetimes.DatetimeIndex>
error message は以下の通りです。 Traceback (most recent call last): File "<ipython-input-182-173f2ae145f2>", line ..., in <module> df.drop(df.loc[sidx:eidx]) File "C:\Users...\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\generic.py", line ..., in drop obj = obj._drop_axis(labels, axis, level=level, errors=errors) File "C:\Users...\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\generic.py", line ..., in _drop_axis new_axis = axis.drop(labels, errors=errors) File "C:\Users...\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\indexes\base.py", line ..., in drop labels[mask]) ValueError: labels [................] not contained in axis
回答1件
あなたの回答
tips
プレビュー