pandasでTimestamp' objectの日付から期間を絞って行を抽出する方法が分からないので、教えて下さい。
下記のデータフレーム から2017-01-06から2017-01-09までの期間のIDを抽出したいのですが上手くいきません。
dataframe名はdf です。
id 日付
0 2017-01-05 00:00:00
1 2017-01-05 00:00:00
2 2017-01-07 00:00:00
3 2017-01-07 00:00:00
4 2017-01-09 00:00:00
5 2017-01-10 00:00:00
6 2017-01-12 00:00:00
7 2017-01-13 00:00:00
試したこと
python
1start_date ='2017-01-05 00:00:00' 2end_date = '2017-01-15 00:00:00' 3 4df[(df.start_date[start_date:end_date])] 5
エラー
TypeError: cannot do slice indexing on <class 'pandas.core.indexes.range.RangeIndex'> with these indexers [2017-01-05 00:00:00] of <class 'str'>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/28 14:53