I want to extract only those rows where specific column values are duplicated.
For example, my source file is
File 1 : CountryA.txt
fruits|count
apple|100
orange|200
orange|245
grapes|230
I need following output
output1.txt
fruits|count
orange|200
orange|245
My code is, is this the correct way of doing this ?
Df1 = pd.read_csv('CountryA.txt',sep="|")
Df1 = Df1[Df1['fruits'].duplicated()]
Df1.to_csv('output1.txt',sep="|")