Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

Boolean indexing pandas

$
0
0

@jefferson77 wrote:

Hello I’m a pandas beginner.
I just want to compare values of a Serie with other values. This is an example

df1 = pd.DataFrame({‘A’: [1,0,1,1,1,0,1,0]})
if df1[“A”] == 0:
df1[“test”] = 1
else:
df1[“test”] = 0

The error is “The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().”
Please help me :disappointed_relieved::disappointed_relieved:

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles