这是我的代码:import pandas as pdimport numpy as npdata = {'ID': [1,2,3,4,5,6,7,8,9], 'Doc':['Order','Order','Inv','Order','Order','Shp','Order', 'Order','Inv'], 'Rep':[101,101,101,102,102,102,103,103,103]}df = pd.DataFrame(data)#df['concat']= (df['ID'].convert_dtypes(convert_string = True) + "1").convert_dtypes(convert_integer = True)df['concat']= (df['ID'].astype(str) + "1").convert_dtypes(convert_integer = True)print(df['concat'].dtype)输出:string为什么不是以及如何获得它?df['concat']Int64
1 回答
翻翻过去那场雪
TA贡献2065条经验 获得超13个赞
尝试
>>> df['concat'] = df['ID'].astype(str).add('1').astype('int64')
0 11
1 21
2 31
3 41
4 51
5 61
6 71
7 81
8 91
Name: ID, dtype: int64
添加回答
举报
0/150
提交
取消