我在 excel 文件的列中应用了处理。现在,我想导出这个处理过的列以及所有其他未处理的列。我的数据(小例子): A B C French house Phone <phone_numbers> English house email blablabla@gmail.com French apartment my name is Liam French house Hello George English apartment Ethan, my phone is <phone_numbers>我的脚本:import reimport pandas as pdfrom pandas import Seriesdf = pd.read_excel('data.xlsx')data = Series.to_string(df['C'])def emails(data): mails = re.compile(r'[\w\.-]+@[\w\.-]+') replace_mails = mails.sub('<adresse_mail>', data) return replace_mailsno_mails = emails(data)no_mails.to_excel('new_data.xlsx')我的输出:AttributeError Traceback (most recent call last)<ipython-input-7-8fd973998937> in <module>() 7 8 no_mails = emails(data)----> 9 no_mails.to_excel('new_data.xlsx')AttributeError: 'str' object has no attribute 'to_excel'良好的输出: A B C French house Phone <phone_numbers> English house email <adresse_mail> French apartment my name is Liam French house Hello George English apartment Ethan, my phone is <phone_numbers>我的脚本工作正常,只有no_mails.to_excel('new_data.xlsx')似乎不起作用。
添加回答
举报
0/150
提交
取消