std : 기준일
mth_bdt : 기준일 월 첫 날짜
mth_edt : 기준일 월 마지막 날짜
from datetime import datetime
for d in range(10):
std = (datetime.strptime('20240201', '%Y%m%d') + timedelta(days = d)).strftime('%Y%m%d')
mth_bdt = (pd.to_datetime(std, format = '%Y%m%d').replace(day = 1).strftime('%Y%m%d')
mth_edt = (pd.to_datetime(std, format = '%Y%m%d') + pd.offsets.MonthEnd(0)).strftime('%Y%m%d')
print(f"std: {std}, mth_bdt : {mth_bdt}, mth_edt : {mth_edt}")
'Python, PySpark' 카테고리의 다른 글
파이토치 CNN 분석 (2) | 2024.08.28 |
---|---|
Jupyterlab에서 텍스트 파일 미리보기(encoding='euc-kr') (0) | 2024.07.15 |
pm4py (0) | 2023.10.31 |
2개의 다른 Decision Tree 의 Feature Importance 수기로 계산하기 (0) | 2023.10.23 |
Python 날짜 스트링 전처리 (0) | 2023.08.16 |