excel效果展示
要求
Full Name以空格为分隔符拆分为两列
import pandas as pd
employee=pd.read_excel("D:\\python_pandas\\sample\\demo11\\Employees.xlsx")
name = employee["Full Name"].str.split(" ",expand=True)
employee["FamalyName"]=name[0]
employee["FirstName"]=name[1]
print(employee.head(30))
输出结果:
ID Full Name FamalyName FirstName
0 1 Syed Abbas Syed Abbas
1 2 Catherine Abel Catherine Abel
2 3 Kim Abercrombie Kim Abercrombie
3 4 Kim Abercrombie Kim Abercrombie
4 5 Kim Abercrombie Kim Abercrombie
5 6 Hazem Abolrous Hazem Abolrous
6 7 Sam Abolrous Sam Abolrous
7 8 Humberto Acevedo Humberto Acevedo
8 9 Gustavo Achong Gustavo Achong
9 10 Pilar Ackerman Pilar Ackerman
10 11 Pilar Ackerman Pilar Ackerman
11 12 Aaron Adams Aaron Adams
12 13 Adam Adams Adam Adams
13 14 Alex Adams Alex Adams
14 15 Alexandra Adams Alexandra Adams
15 16 Allison Adams Allison Adams
16 17 Amanda Adams Amanda Adams
17 18 Amber Adams Amber Adams
18 19 Andrea Adams Andrea Adams
19 20 Angel Adams Angel Adams