Last active
September 13, 2020 16:13
-
-
Save YiLi225/29b966323f030d5efc0ee6fb6a6d660a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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