Skip to content

Instantly share code, notes, and snippets.

@YiLi225
Last active September 21, 2020 02:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YiLi225/b4d0442e32e122d6989a16fc18ca6c88 to your computer and use it in GitHub Desktop.
Save YiLi225/b4d0442e32e122d6989a16fc18ca6c88 to your computer and use it in GitHub Desktop.
## Check if value exists in series -- correct way
'skim, instant' in dairy_table.Food.values ## call the column values
'skim, instant' in list(dairy_table['Food']) ## convert to a list of values
dairy_table.Food.isin(['skim, instant']).any() ## isin() checks against values
dairy_table['Food'].str.contains('skim, instant').any() ## string method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment