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 to handle error unsupported operand type(s)

There is lists :

l_figure_s= [5, 9,  21, 25, 30, 34, 43]
l_figure_e= [8, 16, 24, 28, 33, 37, 46]

Of lists created dataframe :

df1 = pd.DataFrame.from_dict({'starts':l_figure_s,'ends':l_figure_e},dtype=int,orient='index').transpose()

You need to check elements by condition:

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

df1[ df1['starts']<df1['ends'] & df1['starts'].shift(-1)>=df['ends'] ]

The error occurs on the last line,
I think the interpreter sees this condition : Nan >= 46

How to exclude condition check beyond the last line ?

Maybe you need a calculator for df[‘ends’] ?

>Solution :

You have to use parenthesis:

df1[(df1['starts']<df1['ends']) & (df1['starts'].shift(-1)>=df1['ends'])]
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