Pandas dt.to_period() 메서드

to_period() 메서드

dt.to_period(freq=None, axis=0, copy=None)

 

Series의 날짜 또는 시간 정보로 주어진 freq를 Period 형식으로 변환

매개변수 freq에는 변환하려는 기간의 주기를 지정할 수 있고 "M"은 월단위, "Q"는 분기단위, "A"는 연도단위로 사용

여기서 dt 는 DataTime 속성으로 Series에 접근해서 시계열 데이터를 다룰 수 있음

 

예제

참고 

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_period.html

 

pandas.DataFrame.to_period — pandas 2.2.3 documentation

If False then underlying input data is not copied. Note The copy keyword will change behavior in pandas 3.0. Copy-on-Write will be enabled by default, which means that all methods with a copy keyword will use a lazy copy mechanism to defer the copy and ign

pandas.pydata.org

https://www.datamanim.com/dataset/99_pandas/pandasMain.html#grouping