alex_bn_lee

导航

【850】numpy处理日期数据

参考:Add Months to datetime Object in Python


☀☀☀<< 举例 >>☀☀☀

# import packages
import pandas as pd

# adding months to a particular date
present = '2022-05-05'
print('date : ' + present)
new_date = pd.to_datetime(present)+pd.DateOffset(months=5)
print('new date is : '+str(new_date))

调用pd.DataOffset()很好用!

 

posted on 2023-07-03 10:42  McDelfino  阅读(27)  评论(0)    收藏  举报