我的CSV文件有电子邮件地址。其地址不完整。使用python完全识别它们
问题说明
我是使用Python进行数据科学的初学者。
我正在处理一个数据集,在其中必须执行以下任务:
使用Python petl:
I'm a begineer in data science with python. I'm working on a Dataset in which i've to do following tasks: Using the Python petl:
a。 清除 clinics.csv
中的数据。这涉及使用python和Regex对
的电子邮件地址进行标准化,以便它们可用作html链接,并且
a. clean the data in the clinics.csv
. This involves using python and Regex to standardise email addresses so they are usable as a html link, and
b。合并并清理的数据到名为 clinic_locations.csv
的CSV文件中。
b. output the merged and cleaned data into a CSV file with the name clinic_locations.csv
.
到目前为止我能够处理点( b )的一部分,即,我已经轻松地从xml文件中提取了数据并将其与csv文件结合在一起。
但这是问题
So, far i'm able to do handle a part of point (b) i.e. i've easily extracted data from the xml file and combined it with the csv file. But the problem with this is
我无法清除CSV文件的数据
这是我的CSV文件:
ID Name Suburb State Postcode Email
1 Hurstville Clinic Hurstville NSW 1493 hurstville
2 Sydney Centre Clinic Sydney NSW 2000 sydney@myclinic.com.au
3 Auburn Clinic Auburn NSW 2144 auburn@myclinic.com.au
4 Riverwood Clinic Riverwood NSW 2210 riverwood@myclinic.com.au
因为您可以看到电子邮件列中的数据不完整且整个链接无法使用。
谁能从一开始就帮助我。
as you can see the data in email column is incomplete and whole links are unusable. Can anyone help me from starting.
已更新:
我得到的输出是
updated: the output that I'm getting is
ID Name Suburb State Postcode \
0 1 Hurstville Clinic Hurstville NSW 1493
1 2 Sydney Centre Clinic Sydney NSW 2000
2 3 Auburn Clinic Auburn NSW 2144
3 4 Riverwood Clinic Riverwood NSW 2210
4 5 Fingal Bay Clinic Fingal Bay NSW 2315
5 6 Harrington Clinic Harrington NSW 2427
6 7 Back Forest Clinic Back Forest NSW 2535
7 8 Jindabyne Clinic Jindabyne NSW 2627
8 9 Benolong Clinic Benolong NSW 2830
9 10 Melbourne Centre Clinic Melbourne VIC 3000
Email
0 hurstville@myclinic.com.au
1 sydney@myclinic.com.au
2 auburn@myclinic.com.au
3 riverwood@myclinic.com.au
4 fingal bay@myclinic.com.au
5 harrington@myclinic.com.au
6 back forest@myclinic.com.au
7 jindabyne @myclinic.com.au
8 benolong@myclinic.com.au
9 melbourne@myclinic.com.au
正确答案
我希望这对假设您所有电子邮件ID都具有相似域名的人有帮助:
I hope this will help assuming you have similar domain for all email ids:
import pandas as pd
df=pd.read_csv("clinic_locations.csv") #Provide complete path to your file
df['Email']=df['Email'].apply(lambda x: x if '@' in str(x) else str(x) '@myclinic.com.au')
#To see data frame
print(df.head(10))
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcffigj
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20 -
希伯来语的空格句子标记化错误
it1352 06-22