Reputation: 47
I am trying to create a date range with increment 0.01 second using pandas.
For example I have this information:
date = 2017/01/01
start_hour = 0
start_minute = 0
start_second = 0.006392
dt = 0.01
I have tried using
date = pd.date_range('1/1/2011 00:00:00.006392', periods=5, freq='s')
and the result is:
2011-01-01 00:00:00.006392
2011-01-01 00:00:01.006392
2011-01-01 00:00:02.006392
2011-01-01 00:00:03.006392
2011-01-01 00:00:04.006392
From example above shows that time increment is 1 second. I want to change the time increment to become 0.01 second.
Please help
Thank you
Upvotes: 2
Views: 2212
Reputation: 214927
You can use millisecond as the unit, so 0.01 second is 10 millisecond, or 10L/10ms; you can see here for more information:
import pandas as pd
# use L
pd.date_range('1/1/2011 00:00:00.006392', periods=5, freq='10L')
# DatetimeIndex(['2011-01-01 00:00:00.006392', '2011-01-01 00:00:00.016392',
# '2011-01-01 00:00:00.026392', '2011-01-01 00:00:00.036392',
# '2011-01-01 00:00:00.046392'],
# dtype='datetime64[ns]', freq='10L')
# use ms
pd.date_range('1/1/2011 00:00:00.006392', periods=5, freq='10ms')
# DatetimeIndex(['2011-01-01 00:00:00.006392', '2011-01-01 00:00:00.016392',
# '2011-01-01 00:00:00.026392', '2011-01-01 00:00:00.036392',
# '2011-01-01 00:00:00.046392'],
# dtype='datetime64[ns]', freq='10L')
Upvotes: 3