#!/usr/bin/env python # -*- coding: utf8 -*- from decimal import Decimal import warnings try: import unittest2 as unittest except ImportError: import unittest import agate import agatestats agatestats.patch() class TestTable(unittest.TestCase): def setUp(self): self.rows = ( (1, 4, 'a'), (2, 3, 'b'), (None, 2, u'👍') ) self.number_type = agate.Number() self.text_type = agate.Text() self.columns = ( ('one', self.number_type), ('two', self.number_type), ('three', self.text_type)
for r in cpi_and_cl.order_by('CPI 2013 Score').limit(10).rows: print '{}: {} - {}%'.format(r['Country / Territory'], r['CPI 2013 Score'], r['Total (%)']) import numpy #print(numpy.corrcoef(cpi_and_cl.columns['Total (%)'].values(),cpi_and_cl.columns['CPI 2013 Score'].values())[0, 1]) corr = numpy.corrcoef( [float(t) for t in cpi_and_cl.columns['Total (%)'].values()], [float(s) for s in cpi_and_cl.columns['CPI 2013 Score'].values()])[0, 1] print(corr) #print(numpy.corrcoef([float(t) for t in cpi_and_cl.columns['Total (%)'].values()],[float(s) for s in cpi_and_cl.columns['CPI 2013 Score'].values()])[0, 1]) import agatestats agatestats.patch() std_dev_outliers = cpi_and_cl.stdev_outliers('Total (%)', deviations=3, reject=False) len(std_dev_outliers.rows) std_dev_outliers = cpi_and_cl.stdev_outliers('Total (%)', deviations=5, reject=False) len(std_dev_outliers.rows) mad = cpi_and_cl.mad_outliers('Total (%)') for r in mad.rows: print r['Country / Territory'], r['Total (%)']