程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python Chapter 10 data aggregation and grouping operation

編輯:Python

Group data sets and apply a function to each group ( Whether it's aggregation or transformation ), It is usually an important part of data analysis . Loading the dataset 、 The fusion 、 When you're ready , It is usually used to calculate group statistics or generate pivot tables .pandas Provides a flexible and efficient gruopby function , It allows you to slice data sets in a natural way 、 cutting 、 Abstract and so on .

Relational databases and SQL(Structured Query Language, Structured query language ) One of the reasons why it is so popular is that it can easily connect data 、 Filter 、 Transformation and aggregation . however , image SQL The types of grouping operations that such query languages can perform are very limited . In this chapter you will see , because Python and pandas Strong expression skills , We can perform much more complex grouping operations ( Use whatever is acceptable pandas Object or NumPy Array functions ). In this chapter , You will learn :

  • Use one or more keys ( The form can be a function 、 An array or DataFrame Name ) Division pandas object .
  • Calculate overview statistics for groups , Like quantity 、 Mean or standard deviation , Or user-defined functions .
  • Apply intra group conversions or other operations , Normalization 、 Linear regression 、 Ranking or selecting subsets, etc .
  • Calculate pivot table or crosstab .
  • Perform quantile analysis and other statistical grouping analysis .

note : Aggregation of time series data (groupby One of the special uses of ) Also called resampling (resampling), This book will be in 11 It is explained separately in chapter .

10.1 GroupBy Mechanism

Hadley Wickham( Many popular R Author of the language pack ) Created a term for grouping operations "split-apply-combine"( Split - application -


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved