## 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