0

I'm working with a dataframe. How come this filter function returns nothing, not even an error?

print(df.iloc[0,4])

==> a

def filter(x):
   if x in ['a', 'b', 'c']:
       print("yes")

var = df.iloc[0,4]

filter(var)

==> nothing

Umar.H
  • 22,559
  • 7
  • 39
  • 74
Zumplo
  • 150
  • 1
  • 9
  • If var is not in ['a', 'b', 'c'] nothing will happen, as there is no action specified when the if condition is False. – Eric Truett Apr 25 '20 at 22:10
  • 1
    is there a white space you don't see in the result of the first print? – Ben.T Apr 25 '20 at 22:38
  • thanks for your help. You put me on the right track. Answer here https://stackoverflow.com/questions/4843158/check-if-a-python-list-item-contains-a-string-inside-another-string – Zumplo Apr 26 '20 at 06:51

0 Answers0