Open
Description
Code Sample, a copy-pastable example if possible
import pandas as pd
from datetime import datetime as dt
dates = [
dt(2000, 1, 1, 0, 0),
dt(2000, 1, 1, 0, 0, 30),
dt(2000, 1, 1, 0, 1),
dt(2000, 1, 1, 0, 1, 30),
dt(2000, 1, 1, 0, 2),
dt(2000, 1, 1, 0, 2, 30),
dt(2000, 1, 1, 0, 3),
dt(2000, 1, 1, 0, 3, 30),
dt(2000, 1, 1, 0, 4),
dt(2000, 1, 1, 0, 4, 30),
dt(2000, 1, 1, 0, 5),
dt(2000, 1, 1, 0, 5, 30),
dt(2000, 1, 1, 0, 6),
dt(2000, 1, 1, 0, 6, 30)]
idx = pd.DatetimeIndex(dates)
idx.to_period('5T')
Problem description
By changing the period to 5 minutes, I expected the output to be:
PeriodIndex(['2000-01-01 00:00', '2000-01-01 00:00', '2000-01-01 00:00',
'2000-01-01 00:00', '2000-01-01 00:00', '2000-01-01 00:00',
'2000-01-01 00:00', '2000-01-01 00:00', '2000-01-01 00:00',
'2000-01-01 00:00', '2000-01-01 00:05', '2000-01-01 00:05',
'2000-01-01 00:05', '2000-01-01 00:05'],
dtype='period[5T]', freq='5T')
but it is
PeriodIndex(['2000-01-01 00:00', '2000-01-01 00:00', '2000-01-01 00:01',
'2000-01-01 00:01', '2000-01-01 00:02', '2000-01-01 00:02',
'2000-01-01 00:03', '2000-01-01 00:03', '2000-01-01 00:04',
'2000-01-01 00:04', '2000-01-01 00:05', '2000-01-01 00:05',
'2000-01-01 00:06', '2000-01-01 00:06'],
dtype='period[5T]', freq='5T')
Which makes it look like the actual period is one minute ('T') since thats what the output corresponds to, but the freq shows correctly as 5T.
Have I misunderstood what to_period
should return? or is this a bug?
I am using the latest version of pandas (0.23.4)