Last answered:

21 Nov 2022

Posted on:

21 Nov 2022

0

TypeError: ufunc 'bitwise_and' not supported for the input types, and the inputs could not be safely

Hi hope someone know how to resolve this error.
image.png

image.png

1 answers ( 0 marked as helpful)
Instructor
Posted on:

21 Nov 2022

0

Hi Bernie,
thanks for reaching out! From the error I believe that the error comes from the order in which operations are performed in Python. & has a higher priority, compared to <=, that's why you get the error. If you add parentheses in the second comparison like so:

df_spx_ftse_H2_08 = df_spx_ftse_00_10[(df_spx_ftse_00_10.new_date >= '2008-07-01') &
                                      (df_spx_ftse_00_10.new_date <= '2008-12-31')]

you should be alright.
As an aside, I always put parentheses when I have the & or | operator, just to be sure that everything is running smoothly. You'd be surprised how many potential errors you can avoid that way.
Let me know if that works for you.

Best,
365 Eli

Submit an answer