- - - - - - freqm - - if you had dividend dates and percentagesincluding them in the total return per day would look likereturns[dividend_dates+dividend_pcts group transforms and analysis in you learned the basics of computing group statistics and applying your own transformations to groups in dataset let' consider collection of hypothetical stock portfolios first randomly generate broad universe of tickersimport randomrandom seed( import string def rands( )choices string ascii_uppercase return 'join([random choice(choicesfor in xrange( )]tickers np array([rands( for in xrange( )] then create dataframe containing columns representing hypotheticalbut random portfolios for subset of tickersm df dataframe({'momentumnp random randn( 'valuenp random randn( 'shortinterestnp random randn( }index=tickers[: ]nextlet' create random industry classification for the tickers to keep things simplei'll just keep it to industriesstoring the mapping in seriesind_names np array(['financial''tech']sampler np random randint( len(ind_names)nindustries series(ind_names[sampler]index=tickersname='industry'now we can group by industries and carry out group aggregation and transformationsin [ ]by_industry df groupby(industriesin [ ]by_industry mean(out[ ]momentum shortinterest value financial and economic data applications www it-ebooks info