기간을 설정하여 날짜로 for문을 구성해야하는 경우
from datetime import datetime
import pandas
start = '01-27'
end = '02-05'
start = datetime.strptime(start, "%m-%d")
end = datetime.strptime(end, "%m-%d")
dates = [date.strftime("%m-%d") for date in pandas.date_range(start, periods=(end - start).days + 1)]
print (dates)
결과
['01-27', '01-28', '01-29', '01-30', '01-31', '02-01', '02-02', '02-03', '02-04', '02-05']
'IT > Python' 카테고리의 다른 글
Slack으로 알람 받기(Incoming Webhooks) (0) | 2023.05.01 |
---|---|
Python - 불특정 json 묶음(?)에서 특정 value만 뽑기 (0) | 2022.10.10 |
Python - 파일명에 속한 날짜를 기준으로 정렬 (2) | 2022.10.03 |