Example #1
0
 def test_compression(self):
     pth = os.path.join(os.path.curdir, tp, 'data5')
     res = os.path.join(os.path.curdir, rp, 'result_all.csv')
     t = TextConnection(pth)
     t.aggregate_data(fns = True)
     df = read_csv(res)
     self.assertEqual(all(df.sort_index(axis = 1) == t._df.sort_index(axis = 1)), True)        
Example #2
0
 def test_fnf(self):
     pth = os.path.join(os.path.curdir, tp, 'data1')
     res = os.path.join(os.path.curdir, rp, 'result_filter.csv')
     flt = lambda x: True if x[:-4] in ['AAPL', 'ARIA', 'LMT', 'MDLZ'] else False
     t = TextConnection(pth)
     t.aggregate_data(fns = True, fnf = flt)
     df = read_csv(res)
     self.assertEqual(all(df.sort_index(axis = 1) == t._df.sort_index(axis = 1)), True) 
Example #3
0
 def test_aggregate_data(self):
     pth = os.path.join(os.path.curdir, tp, 'data6')
     res = os.path.join(os.path.curdir, rp, 'result_eod.csv')
     t = TextConnection(pth)
     t.aggregate_data()
     print t._df, pth
     df = read_csv(res)
     self.assertEqual(all(df.sort_index(axis = 1) == t._df.sort_index(axis = 1)), True) 
Example #4
0
 def test_after_read(self):
     pth = os.path.join(os.path.curdir, tp, 'data5')
     res = os.path.join(os.path.curdir, rp, 'result_all.csv')
     df = read_csv(res)
     df['add_col'] = df['high'] + df['low']
     def f(x):
         x['add_col'] = x['high'] + x['low']
         return x
     t = TextConnection(pth)
     t.aggregate_data(fns = True, after_read = f)
     self.assertEqual(all(df.sort_index(axis = 1) == t._df.sort_index(axis = 1)), True)