def top_corr(self, df):
        """Give aggregation counts and correlations"""
        tag_freq = df.sum()
        tag_freq.sort(ascending=False)

        corr = df.corr().fillna(1)
        corr_dict = corr.to_dict()
        for tag, count in tag_freq.iteritems():
            print '  %s%s: %s%s%s  (' % (color.Green, tag, color.LightBlue, count, color.Normal),
            tag_corrs = sorted(corr_dict[tag].iteritems(), key=operator.itemgetter(1), reverse=True)
            for corr_tag, value in tag_corrs[:5]:
                if corr_tag != tag and (value > .2):
                    print '%s%s:%s%.1f' % (color.Green, corr_tag, color.LightBlue, value),
            print '%s)' % color.Normal
def top_corr ( self , df ) : tag_freq = df . sum ( ) tag_freq . sort ( ascending = False ) corr = df . corr ( ) . fillna ( 1 ) corr_dict = corr . to_dict ( ) for tag , count in tag_freq . iteritems ( ) : print '  %s%s: %s%s%s  (' % ( color . Green , tag , color . LightBlue , count , color . Normal ) , tag_corrs = sorted ( corr_dict [ tag ] . iteritems ( ) , key = operator . itemgetter ( 1 ) , reverse = True ) for corr_tag , value in tag_corrs [ : 5 ] : if corr_tag != tag and ( value > .2 ) : print '%s%s:%s%.1f' % ( color . Green , corr_tag , color . LightBlue , value ) , print '%s)' % color . Normal
Give aggregation counts and correlations