I'm simply trying to remove duplicates from a csv and then make a new csv file with only the first column and no duplicates.
My terminal shows its working but when then the new csv file still shows all. ???
import pandas as pd
import numpy as np
#df = pd.read_csv('directory.csv',index_col=0,usecols=["From"]),
d = pd.read_csv('directory.csv')
df = pd.DataFrame(d, columns=['From'])
print(
"""
-----this is all phone numbers in header FROM-----
"""
)
print(df)
print(
"""
-----this is only unique values ----
"""
)
df = df.drop_duplicates(subset="From", keep="first", inplace=True)
print(df)
print(
"""
-----now saving to new csv----
"""
)
df.to_csv("uniquePhones.csv")
Terminal python3 csvImport.py
-----this is all phone numbers in header FROM-----
From
0 +34141414)
1 1231231231
2 1231213
3 (+123123123
4 123212313.. ...
692 1231237)
693 A123213616)
694 12321433)
695 1312)
696 1321321)
[697 rows x 1 columns]
-----this is only unique values ----
From
0 +34141414)
1 1231231231
2 1231213
3 (+123123123
4 123212313..
692 1231237)
693 A123213616)
694 12321433)
695 1312)
696 1321321)
[279 rows x 1 columns]
-----now saving to new csv----