Pandas 2.0 pyarrow后端datetime操作

cld4siwp  于 2023-11-15  发布在  其他
关注(0)|答案(1)|浏览(79)

我有以下pandas使用pyarrow后端的对象:

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]

字符串
我想把这些日子推回到月底,类似于我使用pandas日期时间所做的:

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


date32[day][pyarrow]对象的等价操作是什么?

hs1ihplo

hs1ihplo1#

也许只是转换后?

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

字符串

相关问题