menu_sub= menu[menu["Trans Fat"]==0][menu["Cholesterol (% Daily Value)"]==0][menu["Cholesterol (% Daily Value)"]==0]
returns: "Boolean Series key will be reindexed to match DataFrame index. from ipykernel import kernelapp as app"
After searching for a solution people suggested I used '&', but after using that I get a other error..
menu_sub= menu[menu["Trans Fat"]==0 & menu["Cholesterol (% Daily Value)"]==0 & menu["Cholesterol (% Daily Value)"]==0]
returns: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Is there a way to do this in one line? or do have to create 3 different lines?
First you were chain boolean slicing where the boolean series you were slicing with were based off of the original and the slices you were chaining kept getting smaller.
Second, you need to wrap your boolean series in parentheses.
menu_sub= menu[
(menu["Trans Fat"] == 0) &
(menu["Cholesterol (% Daily Value)"] == 0) &
(menu["Cholesterol (% Daily Value)"] == 0)
]
But now you can see you are repeating one condition twice, which I don't understand.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With