pct = pd.read_csv('PHYF111_PCT.csv')
pct.drop('S.NO',axis=1,inplace=True)
pct.fillna(0,inplace=True)
pct
cut = lambda x: x[:11]
pct['Email new']=pct["Email Address"].apply(cut)
pct
该图像是我正在尝试处理的数据框的屏幕截图。 我正在尝试使用 lambda 函数删除电子邮件地址的前 10 个索引。但是,我收到错误“int”类型不可下标。此代码在“名称”列上运行良好。为什么该代码不适用于电子邮件地址,因为即使它们是字符串。
答案 0 :(得分:0)
“Email Address”一栏有缺失值,填0,看第494行