Using timestamp.day() with index

niftynext50_2019[pd.Timestamp(i).day() for i in niftynext50_2019.index[:]]

throws error at ‘for i’.
How can i rectify?

Hi @ambica_v,
What error does it throw? Can you please share a screenshot

Syntax error:Invalid syntax,
^pointing at “for i”

This is invalid, as the code snippet:

returns an object of type Index, which can not be traversed as a list.

but,
wd2018=nifty50_2018.groupby([pd.Timestamp(i).dayofweek for i in nifty50_2018.index[:]])
worked?