【发布时间】:2021-12-06 15:15:54
【问题描述】:
尝试使用日期时间获取月末数据。
我的代码:
monthyear = input("Enter Full Month and Year: ") #Ie September 2021
assessdate = pd.to_datetime(prevdate, format="%B %Y").strftime('%m%d%Y %H:%M')
得到
09012021 00:00
期待:
09/30/2021 00:00
试过了:
monthyear = input("Enter Full Month and Year: ") #Ie September 2021
assessdate = pd.to_datetime(monthyear, format="%B %Y")+MonthEnd(1).dt.strftime('%m%d%Y %H:%M')
【问题讨论】:
标签: pandas