#字符串切片赋值
df['item']=df['item'].astype(str).str[1:]
如果列内容是字符串,可以
df['item']=df['item'].str[1:]
#正则表达式赋值
df['item'] = df['item'].str.extract(r'([0-9]+).')
#astype强制转换
如果试图强制将列转换类型,可以使用df.astype()
例如:
df.astype(int),对应int32
df.astype('int64'),对应int64
df.astype(str),字符串类型
Pandas支持的数据类型:
1. float
2. int
3. bool
4. datetime64[ns]
5. datetime64[ns, tz]
6. timedelta[ns]
7. category
8. object
默认的数据类型是int64,float64