0

i have this line:

logical= [value in line for value in Dictionnary["substance_name"].values]

that gave me this error:

TypeError: 'in <string>' requires string as left operand, not NoneType

This is probably due to some gaps in my dictionnary.

So to fix it I thought about adding this:

logical= [value in line for value in Dictionnary["substance_name"].values and value not None]

By the synthax seems to be incorrect. How can I express it correctly? I edited my code:

logical= [value in line for value in DictionnaireMedicHUG["substance_name"].values] 
            if logical != None:

I am still getting the same error

4
  • 3
    Change and to if. Also, don't you mean .values(), rather than .values? Commented Oct 13, 2020 at 12:57
  • If I use .values() I get TypeError: 'numpy.ndarray' object is not callable Commented Oct 13, 2020 at 13:03
  • OK. I thought we were talking about a dictionary. Commented Oct 13, 2020 at 13:04
  • My bad it is actually a dataframe (pandas). Commented Oct 13, 2020 at 13:04

1 Answer 1

1

Try this:

logical = [value in line for value in DictionnaireMedicHUG["substance_name"].values if logical is not None] 
Sign up to request clarification or add additional context in comments.

1 Comment

Did this help you? @marou95thebest

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.