【发布时间】:2021-04-15 18:13:01
【问题描述】:
我正在尝试将此 (34218.1, 37413.8] 拆分为 2 列,最小值和最大值,但是当我这样做时,这两列代表对象,但我想成为浮点类型。所以这是我的代码:
df['binnedInc'] = df['binnedInc'].str.strip('[]')#I want to remove righ bracket in case it's a problem
df['binnedInc'] = df['binnedInc'].str.strip('()')#I want to remove left bracket
df[["MinInc","MaxInc"]]=df.binnedInc.str.split(expand=True,pat=",")
df['MaxInc'].astype(float)
MinInc object #I got this when i want to see df.type
MaxInc object
所以,我分成 2 列,但后来我无法转换为浮点类型。请帮帮我
【问题讨论】: