一、问题
AttributeError: ‘DatetimeProperties’ object has no attribute ‘weekday_name’
简单测试,运行如下代码:
importpandasaspd# 创建日期dates=pd.Series(pd.date_range("7/26/2021", periods=3, freq="D")) # 查看星期几print(dates.dt.weekday_name) # 只显示数值print(dates.dt.weekday)
二、解决方法
weekday_name改为day_name()
importpandasaspd# 创建日期dates=pd.Series(pd.date_range("7/26/2021", periods=3, freq="D")) # 查看星期几print(dates.dt.day_name()) # 只显示数值print(dates.dt.weekday)
结果如下:
推荐阅读:
https://blog.csdn.net/weixin_43896318/article/details/106262821
https://blog.csdn.net/IT_SoftEngineer/article/details/107420663
https://www.pythonheidong.com/blog/article/586790/1e0189487630dc9e2d5c/