4

okay so I have two data frames both with datetime as indices.

When I call df1 index, I get:

df1.index[0]
Timestamp('2016-03-04 00:00:00')

when I call df2 index, i get:

df2.index[0]
Timestamp('2016-03-11 00:00:00', freq='W-FRI')

I'm trying to remove the freq='W-FRI' part. I want my second data frame (df2) to return the follow when I call for the first index:

df2.index[0]
Timestamp('2016-03-03 00:00:00')

Thanks so much. This small difference is not allowing me to index my data frames with dates.

  • So in addition to removing the `freq` part, you need it to shift the dates forward by 8 days, or is that a typo? – ALollz Nov 08 '19 at 19:47

1 Answers1

6

You have a DatetimeIndex with a freq. Set it to None

import pandas as pd

idx = pd.date_range('2010-01-01', freq='W-FRI', periods=10)
idx[0]
#Timestamp('2010-01-01 00:00:00', freq='W-FRI')

idx.freq=None
idx[0]
#Timestamp('2010-01-01 00:00:00')

All DatetimeIndex objects have a frequency attribute, the default is None.

pd.DatetimeIndex(['2010-01-01', '2011-01-02'])
#DatetimeIndex(['2010-01-01', '2011-01-02'], dtype='datetime64[ns]', freq=None)
ALollz
  • 57,915
  • 7
  • 66
  • 89