AttributeError: 'DatetimeProperties' object has no attribute 'weekday_name'
时间: 2023-11-26 19:49:07 浏览: 202
【Python】AttributeError: ‘AutoSchema’ object has no attribute ‘get_link’
5星 · 资源好评率100%
这个错误是因为你使用了已经被弃用的weekday_name参数,而该参数已经被day_name()所替代。你可以将weekday_name替换为day_name()来解决这个问题。例如:
```python
import pandas as pd
df = pd.DataFrame({'date': ['2022-01-01', '2022-01-02', '2022-01-03']})
df['date'] = pd.to_datetime(df['date'])
df['weekday'] = df['date'].dt.day_name()
print(df)
```
输出:
```
date weekday
0 2022-01-01 Saturday
1 2022-01-02 Sunday
2 2022-01-03 Monday
```
阅读全文