Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between pd.DatetimeIndex.weekday and pd.DatetimeIndex.dayofweek

Tags:

python

pandas

In pandas datetimeindex, dayofweek and weekday seem to be the same. Are they just aliases of each other? I discovered these functions here

like image 236
Kevin Wang Avatar asked Sep 19 '25 19:09

Kevin Wang


1 Answers

Based on the pandas source code definition of DatetimeIndex, weekday is just an alias for dayofweek, so there is no difference.

class DatetimeIndex:
    ...
    dayofweek = _field_accessor('dayofweek', 'dow',
                                "The day of the week with Monday=0, Sunday=6")
    weekday = dayofweek

Source: https://github.com/pandas-dev/pandas/blob/50930a9879b580ab4f30d8b741229391e41afa76/pandas/tseries/index.py#L1547

like image 148
bakkal Avatar answered Sep 22 '25 10:09

bakkal