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

How do I delete a row when two dataframes in pandas do not have the same length? – python

I have two dataframes in pandas:

df1 can have 365 or 366 rows

df2 has 366 rows

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

If df1 and df2 have the same number of rows I want to output "same row size".
If, df1 and df2 don’t have the same sizes I want to delete row 59 at df2.

all because of leap year 🙂

>Solution :

Use:

if len(df1) != len(df2):
    df2 = df2.drop(59)

Another idea is remove row with 29. Feb, how do it depends of data.

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