111

I am new to Pandas, and am trying to use date_range. I came across all kinds of good things for freq, like BME and BMS and I would like to be able to quickly look up the proper strings to get what I want. Yesterday I found a nicely formatted table somewhere in the documentation, but the title of the table was so obtuse that I can not use search to find it again today.

What values are valid in Pandas 'Freq' tags?

Philip Couling
  • 10,963
  • 4
  • 37
  • 63
sundowner
  • 1,258
  • 2
  • 10
  • 7
  • 5
    Too bad the question is closed, because this is really a problem to understand the confusing Pandas documentation of [Period](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Period.html#pandas.Period) which tells nothing about `freq` specifiers, while [Period.strftime()](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Period.strftime.html#pandas-period-strftime) claims to return "*the string representation of the Period*", which apparently it something else, as e.g. `M` and `m` for minute and month actually create the same object of `freq='M'`... – mins Dec 13 '20 at 10:49
  • Related explanation of [DateOffset](https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#dateoffset-objects) (same page than the one linked in the selected answer, but starts earlier). – mins Dec 13 '20 at 11:24
  • I've edited this question to try to bring it back on topic for SO without changing it's meaning. – Philip Couling May 19 '21 at 12:42

1 Answers1

168

You can find it called Offset Aliases:

A number of string aliases are given to useful common time series frequencies. We will refer to these aliases as offset aliases.

Alias    Description
B        business day frequency
C        custom business day frequency
D        calendar day frequency
W        weekly frequency
M        month end frequency
SM       semi-month end frequency (15th and end of month)
BM       business month end frequency
CBM      custom business month end frequency
MS       month start frequency
SMS      semi-month start frequency (1st and 15th)
BMS      business month start frequency
CBMS     custom business month start frequency
Q        quarter end frequency
BQ       business quarter end frequency
QS       quarter start frequency
BQS      business quarter start frequency
A, Y     year end frequency
BA, BY   business year end frequency
AS, YS   year start frequency
BAS, BYS business year start frequency
BH       business hour frequency
H        hourly frequency
T, min   minutely frequency
S        secondly frequency
L, ms    milliseconds
U, us    microseconds
N        nanoseconds
jezrael
  • 629,482
  • 62
  • 918
  • 895
  • 16
    Thanks! I KNEW that it was a term that I would never search for - "Offset aliases"! It would be helpful to newcomers if the freq parameter described its expected value as an 'offset alias'. – sundowner Feb 11 '16 at 12:26
  • 1
    Is there a variable in the pandas module that contains the list of offset strings? – BallpointBen Jan 17 '19 at 18:40
  • 2
    You can see all the offset values here: `pd.tseries.offsets.__all__` You can see all of the valid timedeltas here: https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.Timedelta.html – jackalack Oct 02 '19 at 18:52