728x90
날짜
-
[Pandas] 날짜 주차 만들기<Python> 2022. 7. 19. 15:06
# n주차 만들기 from datetime import datetime, timedelta def get_date(y, m, d): s = f'{y:04d}-{m:02d}-{d:02d}' return datetime.strptime(s, '%Y-%m-%d') def get_week_no(y, m, d): target = get_date(y, m, d) firstday = target.replace(day=1) if firstday.weekday() == 6: origin = firstday elif firstday.weekday()