这是一个包含数据和非ascii字符的列
Summary 1
United Kingdom - ��Global Consumer Technology - ��American Express
United Kingdom - ��VP Technology - Founder - ��Hogarth Worldwide
Aberdeen - ��SeniorCore Analysis Specialist - ��COREX Group
London, - ��ED, Equit Technology, London - ��Morgan Stanley
United Kingdom - ��Chief Officer, Group Technology - ��BP
如何将它们拆分并保存在不同的列中
我使用的代码是:
import io
import pandas as pd
df = pd.read_csv("/home/vipul/Desktop/dataminer.csv", sep='\s*\+.*?-\s*')
df = df.reset_index()
df.columns = ["First Name", "Last Name", "Email", "Profile URL", "Summary 1", "Summary 2"]
df.to_csv("/home/vipul/Desktop/new.csv")
另一种方法:
使用此函数可以使用ord内置函数提取assci char(其中Unicode码位优于128)
并将其应用于列。你知道吗
结果如下:
比如说,你有一个列在一个系列中,像这样:
选项1
展开this answer,可以使用
str.split
拆分非ascii字符:选项2
str.extractall
+unstack
:相关问题 更多 >
编程相关推荐