Function Application Continued Aggregation Groupby...
Aggregation(group by) - A groupby operation involves some combination of splitting the object, applying a function, and combining the results. This can be used to group large amounts of data and compute operations on these groups. Groupby function works when you have categorical data as we have in the weather data below. Here 'weather', 'Year'and 'State'are all categorical. Groupby operation involves one of the following operations. Splitting the Object Applying a function Combining the results gp = df.groupby(['Weather','State']) for name,group in gp: print(name) print(group) Output:- 1. Splitting the object - import pandas as pd weather_data = {'Weather': ['Rainy', 'Stormy', 'Sunny', 'Cloudy', 'Rainy', 'Sunny', 'Cloudy', 'Rainy', 'Stormy', 'Cloudy', 'Sunny', 'Sunny'], 'State': ['CG...
Comments
Post a Comment