简体   繁体   English

研究Python dataFrame

[英]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.我有一个 dataframe 由一个“字母”列组成,其中包含从 A 到 Z 的字母,以及一个“车道”列,其中包含 0 和 1。我想知道是否有字母 H,如果有,在车道上有多少次0 以及在第 1 车道上的次数。

Basically I would like to know: the number of 'H' on each track (0 and 1).基本上我想知道:每条轨道(0和1)上“H”的数量。

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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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