简体   繁体   English

Pandas dataframe 找到平均值

[英]Pandas dataframe finding the mean

在此处输入图像描述

I have a dataframe that looks like the attached image.我有一个 dataframe 看起来像所附图像。 I want to find the mean for every finalAward_band 'value'.我想找到每个 finalAward_band '值'的平均值。 I'm not sure how to do this.我不知道该怎么做。

str.contains can be used to perform either substring searches or regex based search. str.contains可用于执行 substring 搜索或基于正则表达式的搜索。 The search defaults to regex-based unless you explicitly disable it.搜索默认为基于正则表达式,除非您明确禁用它。

Sometimes regex search is not required, so specify regex=False to disable it.有时不需要正则表达式搜索,因此指定 regex=False 以禁用它。

#select all rows containing "finalAward_band"
df1[df1['col'].str.contains('finalAward_band', regex=False)]
# same as df1[df1['col'].str.contains('finalAward_band')] but faster.

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

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