Skip to content

Instantly share code, notes, and snippets.

@YiLi225

YiLi225/where.py

Last active Sep 13, 2020
Embed
What would you like to do?
## where() to replace values
food_names_list = ["Cows' milk, whole", 'skim', 'Buttermilk, cultured']
boolean_idx = dairy_table["Food"].isin(food_names_list)
dairy_table['Food'].where(boolean_idx, other='Others')
Out[187]:
index0 Cows' milk, whole
index1 skim
index2 Buttermilk, cultured
index3 Others
index4 Others
......
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment