import pandas as pd
data = pd.DataFrame({'Country':['China','American','Japan'],
'City': ['shanghai|Shenzhen|beijing','New York|shanghai|Shenzhen|beijing | Texas','Tokyo|Osaka']
})
变化过程:
data1 = data[‘City’].str.split(‘|’,expand=True).stack().reset_index(level =1,drop = True).rename(‘City_split’)
data1