简体   繁体   中英

Pandas dataframe finding the mean

在此处输入图像描述

I have a dataframe that looks like the attached image. I want to find the mean for every finalAward_band 'value'. I'm not sure how to do this.

str.contains can be used to perform either substring searches or regex based search. The search defaults to regex-based unless you explicitly disable it.

Sometimes regex search is not required, so specify regex=False to disable it.

#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.

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