一些字符串问题反映在Python中的Dataframe
虽然我尝试拆分第二个' _'一个字符串,python返回错误!
import pandas as pd
from pandas import DataFrame, Series
wkRep = pd.read_csv('filepath.csv')
df = DataFrame(wkRep,columns=['Src','Campaign','Region','Profit','Purchased'])
df['Region']=df.Campaign.apply(lambda x: x.split('_').str[1])
df
AttributeError: 'list' object has no attribute 'str'
广告系列的示例如下所示:
AAA_BBB_New Zeon_Dec 25 2017
我只想将 New Zeon 放入Region中,成为Dataframe中的新列。