简体   繁体   中英

Research in a Python dataFrame

I have a dataframe composed of a column 'Letter' filled with letter going from A to Z and a column 'Lane' filled with 0 and 1. I would like to know if there is the letter H and if yes how many times on lane 0 and how many times on lane 1.

Basically I would like to know: the number of 'H' on each track (0 and 1).

In addition I would like to know how to perform a multiple search. That is to say search two letters at the same time?

Can someone please help me?

df[(df['Letter'] = 'H') & (df['Lane'] == 0)].count()
df[(df['Letter'] = 'H') & (df['Lane'] == 1)].count()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM