Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Group by date range and check duplicate pandas

I am trying to see if I can find duplicate records happened in the year

I know how to find when it is just the year but the date range and find the duplicate and remove the duplicate seems a bit tough. I am beginner so pleas can anyone help ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use:

out = df[~df.loc[df['Date'].str.contains('2021')].duplicated(keep=False)
            .reindex(df.index, fill_value=False)]
print(out)

# Output
         Date Transaction
0  31/12/2020   PURCHASES
1  31/12/2020       Sales
2  31/12/2020       Sales
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading