【发布时间】:2021-07-10 00:39:05
【问题描述】:
我想使用 phonenumbers 库从我的数据框中检查多个电话号码 https://pypi.org/project/phonenumbers/
我想验证电话号码,最终我想知道该号码来自哪个国家/地区。比如:
| contact | phoneNumber | phoneCheck | phoneCountry |
|---|---|---|---|
| 1 | 31650868016 | True | Netherlands |
| 2 | 447986123456 | True | United Kingdom |
| 3 | 55677 | False |
我使用了这个解决方案:https://stackoverflow.com/a/56782746 我做了一个国家专栏。
但我想使用 phonenumbers.is_valid_number() 函数,最终使用 geocoder.description_for_number() 函数。
df['phone_number_clean'] = df.apply(lambda x:
phonenumbers.is_valid_number(phonenumbers.is_valid_number(str(x.phoneNumber),
str(x.Country)),
axis='columns'))
错误:AttributeError:“系列”对象没有属性“电话号码”
【问题讨论】:
标签: python pandas libphonenumber