2016-10-10 1 views
2

私はPandasを使用して、定期的なペイデイに対応するエントリを持つPythonでタイムインデックスを作成しようとしています。具体的には、インデックスを月の第1金曜日と第3金曜日に対応させたいと思います。誰かがこれを示すコードスニペットを与えてもらえますか?パンダを使ってペイデイのDateOffsetを作成する

ような何か:

import pandas as pd 
idx = pd.date_range("2016-10-10", periods=26, freq=<offset here?>) 
+0

を。おそらく 'dateutil'を使用して一連のdatetimeオブジェクトを構築する必要があります。参照してください:http://stackoverflow.com/questions/28680896/how-can-i-get-the-3rd-friday-of-a-month-in-python –

答えて

2

この試してみてください。私はパンダは、この組み込み機能を持っているかわからない

In [6]: pd.date_range("2016-10-10", periods=26, freq='WOM-1FRI').union(pd.date_range("2016-10-10", periods=26, freq='WOM-3FRI')) 
Out[6]: 
DatetimeIndex(['2016-10-21', '2016-11-04', '2016-11-18', '2016-12-02', '2016-12-16', '2017-01-06', '2017-01-20', '2017-02-03', '2017-02-17', 
'2017-03-03', '2017-03-17', '2017-04-07', '2017-04-21', 
       '2017-05-05', '2017-05-19', '2017-06-02', '2017-06-16', '2017-07-07', '2017-07-21', '2017-08-04', '2017-08-18', '2017-09-01', 
'2017-09-15', '2017-10-06', '2017-10-20', '2017-11-03', 
       '2017-11-17', '2017-12-01', '2017-12-15', '2018-01-05', '2018-01-19', '2018-02-02', '2018-02-16', '2018-03-02', '2018-03-16', 
'2018-04-06', '2018-04-20', '2018-05-04', '2018-05-18', 
       '2018-06-01', '2018-06-15', '2018-07-06', '2018-07-20', '2018-08-03', '2018-08-17', '2018-09-07', '2018-09-21', '2018-10-05', 
'2018-10-19', '2018-11-02', '2018-11-16', '2018-12-07'], 
       dtype='datetime64[ns]', freq=None) 
+0

滑らかな、これは動作します。ありがとう! – themaestro

+0

@themaestro、あなたは歓迎です:) – MaxU

関連する問題