Created
March 18, 2021 17:23
-
-
Save pietrocolombo/2b01922a753cf8b1d17b49342527cf51 to your computer and use it in GitHub Desktop.
Delete duplicate contacts and contacts with more or less than 13 digits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
contacts = pd.read_csv("contacts.csv") | |
contacts.drop_duplicates(subset=['Numero di telefono']) # name of the column that identifies the telephone number | |
# clears numbers that have more than 13 digits | |
index_to_drop = contacts[contacts['Numero di telefono'].map(len) != 13].index | |
contacts.drop(index_to_drop, inplace=True) | |
# save in a new csv | |
contacts.to_csv('contacts_new.csv', index = False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment