Python-pandas-date-functionality
提供:Dev Guides
Pythonパンダ-日付機能
時系列を拡張する日付機能は、財務データ分析で重要な役割を果たします。 日付データで作業している間、私たちは頻繁に次のものに遭遇します-
- 日付のシーケンスを生成する
- 日付シリーズを異なる頻度に変換する
日付の範囲を作成する
期間と頻度を指定して* date.range()*関数を使用すると、日付系列を作成できます。 デフォルトでは、範囲の頻度は日数です。
その*出力*は次のとおりです-
日付の頻度を変更する
その*出力*は次のとおりです-
bdate_range
bdate_range()は営業日範囲を表します。 date_range()とは異なり、土曜日と日曜日は除外されます。
その*出力*は次のとおりです-
3月3日以降、日付は4日と5日を除いて6月3日にジャンプします。 カレンダーを確認してください。
その*出力*は次のとおりです-
オフセットエイリアス
有用な一般的な時系列周波数に、多くの文字列エイリアスが与えられます。 これらのエイリアスをオフセットエイリアスと呼びます。
Alias | Description | Alias | Description |
---|---|---|---|
B | business day frequency | BQS | business quarter start frequency |
D | calendar day frequency | A | annual(Year) end frequency |
W | weekly frequency | BA | business year end frequency |
M | month end frequency | BAS | business year start frequency |
SM | semi-month end frequency | BH | business hour frequency |
BM | business month end frequency | H | hourly frequency |
MS | month start frequency | T, min | minutely frequency |
SMS | SMS semi month start frequency | S | secondly frequency |
BMS | business month start frequency | L, ms | milliseconds |
Q | quarter end frequency | U, us | microseconds |
BQ | business quarter end frequency | N | nanoseconds |
QS | quarter start frequency |