I am trying to set the first day of the week as Tuesday in pandas using this pandas.DatetimeIndex.dayofweek((Tuesday =0,Monday=6)). I am getting this ERROR: 'Series' object is not callable, can someone help me to figure out this issue.
Asked
Active
Viewed 373 times
1
-
Can you add data sample? Maybe need `df['col'].dt.dayofweek` – jezrael Jun 29 '18 at 05:03
-
yup @jezrael I tried with that one but same error – Phanendra Nath Jun 29 '18 at 05:06
-
1OK, check [how to provide a great pandas example](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) as well as how to provide a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) and revise your question accordingly – jezrael Jun 29 '18 at 05:07
1 Answers
1
Best I can do for you is:
tidx = pd.date_range('2018-01-01', periods=7)
(tidx.dayofweek - 2) % 7
Int64Index([5, 6, 0, 1, 2, 3, 4], dtype='int64')
Or define a subclass
class DTI(pd.DatetimeIndex):
@property
def dayofweek(self):
return (super().dayofweek - 2) % 7
dti = DTI(tidx)
dti.dayofweek
Int64Index([5, 6, 0, 1, 2, 3, 4], dtype='int64')

piRSquared
- 285,575
- 57
- 475
- 624