Pandas 2.0 pyarrow backend datetime operation
Asked Answered
F

1

6

I have the following pandas dataframe object using the pyarrow back end:

crsp_m.info(verbose = True)

out:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 4921811 entries, 0 to 4921810
Data columns (total 87 columns):
 #   Column             Dtype               
---  ------             -----               
 0   permno             int64[pyarrow]      
 1   secinfostartdt     date32[day][pyarrow]
 2   secinfoenddt       date32[day][pyarrow]
 3   securitybegdt      date32[day][pyarrow]
 4   securityenddt      date32[day][pyarrow]

I want to push back theses days to the month end similiar to what I did using the pandas datetime:

crsp_m["date"] = pd.to_datetime(crsp_m.date)
crsp_m["date"] = crsp_m.date + pd.tseries.offsets.MonthEnd(0)

What would be equavalent operation for date32[day][pyarrow] object?

Friend answered 19/4, 2023 at 17:50 Comment(0)
I
0

Maybe just convert afterwards?

crsp_m["date"] = (pd.to_datetime(crsp_m.date) + pd.tseries.offsets.MonthEnd(0)).astype("date32[pyarrow]")
Indurate answered 8/11, 2023 at 15:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.