Reputation: 7273
I am trying to look for a solution for the parameter freq
in the pandas.date_range
. I have seen that the default value is D
which is for the daily. So, I thought for minutes M
could be used. But I got monthly output dataframes.
I have gone through the examples from the documenation, but I could not see anything related to minute-wise date_range
. See the what following:
>>> pd.date_range(start='1/1/2018', periods=5, freq='M')
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31', '2018-04-30',
'2018-05-31'],
dtype='datetime64[ns]', freq='M')
So how I can get the minute values using the Pandas.date_range()
?
Let me know
Upvotes: 0
Views: 3007
Reputation: 863701
Use T
or Min
, M
is for end of months offset:
dates = pd.date_range(start='1/1/2018', periods=5, freq='T')
print (dates)
DatetimeIndex(['2018-01-01 00:00:00', '2018-01-01 00:01:00',
'2018-01-01 00:02:00', '2018-01-01 00:03:00',
'2018-01-01 00:04:00'],
dtype='datetime64[ns]', freq='T')
dates = pd.date_range(start='1/1/2018', periods=5, freq='Min')
print (dates)
DatetimeIndex(['2018-01-01 00:00:00', '2018-01-01 00:01:00',
'2018-01-01 00:02:00', '2018-01-01 00:03:00',
'2018-01-01 00:04:00'],
dtype='datetime64[ns]', freq='T')
Upvotes: 6