我正在处理一个数据框,其一列是对象类型:
例子:name 36512 non-null object
我尝试了以下但没有成功
> name_str = autos['name'].to_string()
> print(type(name_str)) # this makes the name_str as type string
> autos['name'] = name_str # putting it back in the data frame brought it back to type object
另外,尝试了以下方法:
> import json
> autos['name'] = json.dumps(name_str)
我的目标是使用拆分前两个单词split('_')
,但除非类型是字符串,否则无法这样做
例子:BMW_740i_4_4_Liter_HAMANN_UMBAU_Mega_Optik
输出:['BMW', '740i']
在新列中