python pandas 获取时间列表

代码:

1 import pandas as pd
2 def get_date_list(begin_date,end_date):
3     date_list = [x.strftime('%Y-%m-%d') for x in list(pd.date_range(start=begin_date, end=end_date))]
4     return date_list
5 ### 可以测试
6 Times=get_date_list('2018-06-01','2018-06-08')
7 for t in Times:
8     print(t)
9     print(type(t))

 

posted @ 2020-10-23 20:41  博二爷  阅读(704)  评论(0编辑  收藏  举报