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

Getting typerror: bad operand for unary ~: 'Timestamp'

I have a dataframe in a dataframe for my source data. I am trying to sort the internal dataframe for max on date and then take the inverse of that for the remaining rows. Here’s a sample of the code:

for cdf in dfile:
    if caseid == 'curr':
        df = dfile[cdf]['Date'].max() #this returns the correct value
        dfile = dfile[~df]

I’m getting the typeError: bad operand type for unary ~: ‘Timestamp’

What am I missing in the inverse mask/filter?

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 cann’t use ~ to Timestamp object, you can try boolean masking

        dfile = dfile[dfile['Date'] != df]
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