ks examplegroup weighted average and correlation under the split-apply-combine paradigm of groupbyoperations between columns in dataframe or two seriessuch group weighted averagebecome routine affair as an exampletake this dataset containing group keysvaluesand some weightsin [ ]df dataframe({'category'[' '' '' '' '' '' '' '' ']'data'np random randn( )'weights'np random rand( )}in [ ]df out[ ]category data - - - - weights the group weighted average by category would then bein [ ]grouped df groupby('category'in [ ]get_wavg lambda gnp average( ['data']weights= ['weights']in [ ]grouped apply(get_wavgout[ ]category - as less trivial exampleconsider data set from yahoofinance containing end of day prices for few stocks and the & index (the spx ticker)in [ ]close_px pd read_csv('ch /stock_px csv'parse_dates=trueindex_col= in [ ]close_px out[ ]datetimeindex entries : : to : : data columnsaapl non-null values msft non-null values xom non-null values spx non-null values dtypesfloat ( group-wise operations and transformations www it-ebooks info