Tag Archives: time series

AttributeError: DatetimeProperties object has no attribute

1.Question

AttributeError: ‘DatetimeProperties’ object has no attribute ‘weekday_ name’

Simple test, run the following code:

import pandas as pd

# Create dates
dates = pd.Series(pd.date_range("7/26/2021", periods=3, freq="D"))
# Check the day of the week
print(dates.dt.weekday_name)
# Show only values
print(dates.dt.weekday)

2.Solution

weekday_ Change name to day_ name()

import pandas as pd

# Create dates
dates = pd.Series(pd.date_range("7/26/2021", periods=3, freq="D"))
# Check the day of the week
print(dates.dt.day_name())
# Show only values
print(dates.dt.weekday)

For example:

Type