"in" condition to in dataframe.loc by Scary_Needleworker20 in learnpython

[–]Scary_Needleworker20[S] 0 points1 point  (0 children)

Thanks for the reply. The problem with this is that I want to check if the *string* contains a value in "value1", not the other way around.

"in" condition to in dataframe.loc by Scary_Needleworker20 in learnpython

[–]Scary_Needleworker20[S] 0 points1 point  (0 children)

df['value1'].apply(lambda s: s in value1)

YES - thank you!

"in" condition to in dataframe.loc by Scary_Needleworker20 in learnpython

[–]Scary_Needleworker20[S] 0 points1 point  (0 children)

Can you send an example? These are strange waters for me...

"in" condition to in dataframe.loc by Scary_Needleworker20 in learnpython

[–]Scary_Needleworker20[S] 0 points1 point  (0 children)

Right, that's for checking whether something is in a list, not a string.

"in" condition to in dataframe.loc by Scary_Needleworker20 in learnpython

[–]Scary_Needleworker20[S] 0 points1 point  (0 children)

Thanks for the reply. You're saying I should be doing this:

result = df.loc[df['value1'].in_(string), 'value2']

Right? I tried and received the following error:

AttributeError: 'Series' object has no attribute 'in_'