Seydou GORO
Seydou GORO

Reputation: 1285

How to slice on values instead of index

I have this panda series

mydata=pd.Series([True,False,False,True],index=["A","B","C","D"])

and I want to slice it so that I could have a dataset with the value=True

A    True
D    True
dtype: bool

I tried this: mydata["True"] but it doesn't work

Upvotes: 1

Views: 68

Answers (1)

jahantaila
jahantaila

Reputation: 908

You should set the mydata index to True.

mydata[mydata == True] 

Upvotes: 1

Related Questions