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

searching/filtering on negative days and time in column

I want to filter/search on negative dates/times in a column. I already filtered the difference between dates, dropped NaN and create frame via:

df = (df['date1'] - df['date2']).dropna().to_frame(name=None) 

Result of dataset

    0
0   8 days 00:00:00
1   8 days 00:00:00
2   43 days 00:00:00
3   -42 days 06:50:00
4   147 days 23:00:00

I tried this:

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

I tried using timedelta or searching on values but that did not work.

Expected result

    0
3   -42 days 06:50:00

Appreciate the help and effort. Thank you!

>Solution :

Filter negative Timedeltas from subtracted Series:

s = df['date1'] - df['date2']

out = s[s < pd.Timedelta(0)].to_frame(0) 
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