import os from perfin import importutils as iu from perfin import analyticsutils as au # read the environment variable which points to the .csv files filepath = os.environ['PERFIN_FILES'] print('filepath', filepath) # import the .csv files and convert the first column to the datetimeindex data = iu.import_csvs_from_directory(filepath, 1) print('raw data', data) # calculate the savings savings = au.get_savings(data) print('savings', savings) # get the stdev of the savings stdev = au.get_stdev(savings) print('stdev', stdev) # print the available variables print('following variables are available now ', ['data', 'savings', 'stdev'])
def test_getsavings_rows(self): self.assertEqual( len(au.get_savings(self.data_datetimeindex, aggregation_period='W')), 75) self.assertEqual(len(au.get_savings(self.data_datetimeindex)), 18)
def test_getsavings_aggregates(self): self.assertAlmostEqual( au.get_savings( self.data_datetimeindex)['2016-12']['Debit'].iloc[0], 1882.85)
def test_getsavings_non_datetimeindex(self): self.assertTrue(au.get_savings(self.data_no_datetimeindex).empty)