Groupby - Transformations & Filtrations
b. Transformations - This function lets you change the data elements into some other value. Example:- import pandas as pd import numpy as np weather_data = {'Weather': ['Rainy', 'Stormy', 'Sunny', 'Cloudy', 'Rainy', 'Sunny', 'Cloudy', 'Rainy', 'Stormy', 'Cloudy', 'Sunny', 'Sunny'], 'State': ['CG', 'AP', 'HP', 'MP', 'HY','DH' ,'CG' ,'HP','AP' , 'MP','CG','AP'], 'Year': [2014,2015,2014,2015,2014,2015,2016,2017,2016,2014,2015,2017], 'Humidity':[3.4,2.3,3.2,4.7,5.8,8.1,3.2,3.5,7.3,1.1,1.2,2.3]} df = pd.DataFrame(weather_data) gp = df.groupby('Year') print(gp['Humidity']. transform ( lambda x: x*100 )) Output:- 0 340.0 1 230.0 2 320.0 3 470.0 4 580.0 5 810.0 6 320.0 7 350.0 8 730.0 9 1...