Learn practical skills, build real-world projects, and advance your career

Grouping and aggregation are two of the most frequently used operations in data analysis, especially while performing exploratory data analysis (EDA), where it is common to compare summary statistics across groups of data.

As an example, in the weather time-series data that you are working with, you may want to compare the average rainfall of various regions or compare temperature across different locations.

A grouping analysis can be thought of as having the following three parts:

1. Splitting the data into groups (e.g., groups of location, year, and month)
2. Applying a function on each group (e.g., mean, max, and min)
3. Combining the results into a data structure showing summary statistics
import pandas as pd
# Reading weather data and display the data
weather_data=pd.read_csv("C:\\Users\\USER\\Desktop\\upgrad\\Pandas\\weatherdata.csv",header=0)
weather_data.head()
weather_data['year']=pd.DatetimeIndex(weather_data['Date']).year
weather_data['month']=pd.DatetimeIndex(weather_data['Date']).month
weather_data['Dateofmonth']=pd.DatetimeIndex(weather_data['Date']).day
weather_data.head()