Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pd.generate_date

>>> pd.date_range(start='2018-04-24', end='2018-04-27', periods=3)
DatetimeIndex(['2018-04-24 00:00:00', '2018-04-25 12:00:00',
               '2018-04-27 00:00:00'],
              dtype='datetime64[ns]', freq=None)

pd.date_range(start, periods=10, freq="2h20min")
Out[240]: 
DatetimeIndex(['2011-01-01 00:00:00', '2011-01-01 02:20:00',
               '2011-01-01 04:40:00', '2011-01-01 07:00:00',
               '2011-01-01 09:20:00', '2011-01-01 11:40:00',
               '2011-01-01 14:00:00', '2011-01-01 16:20:00',
               '2011-01-01 18:40:00', '2011-01-01 21:00:00'],
              dtype='datetime64[ns]', freq='140T')

pd.date_range(start, periods=10, freq="1D10U")
Out[241]: 
DatetimeIndex([       '2011-01-01 00:00:00', '2011-01-02 00:00:00.000010',
               '2011-01-03 00:00:00.000020', '2011-01-04 00:00:00.000030',
               '2011-01-05 00:00:00.000040', '2011-01-06 00:00:00.000050',
               '2011-01-07 00:00:00.000060', '2011-01-08 00:00:00.000070',
               '2011-01-09 00:00:00.000080', '2011-01-10 00:00:00.000090'],
              dtype='datetime64[ns]', freq='86400000010U')

freq aliases

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
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
7+5 =