Exemplo n.º 1
0
 def test_write_grouped_data_to_file(self, sample_data):
     rev = GrossRevenue(aligned_data=sample_data)
     rev.add_revenue_column()
     subdf = rev.subset_data(subset_on="peak")
     grouped = rev.group_data(subdf)
     outfile = "peak-data.csv"
     rev.save_grouped_data(grouped, outfile)
     assert os.path.isfile(outfile)
Exemplo n.º 2
0
 def test_groupby_runs_default_methods(self, sample_data):
     rev = GrossRevenue(aligned_data=sample_data)
     rev.add_revenue_column()
     subdf = rev.subset_data(subset_on="peak")
     grouped = rev.group_data(subdf)
     assert grouped.shape == (12, 4)
     print(grouped)
     assert grouped.index.min() == 1
     assert grouped.index.max() == 12
Exemplo n.º 3
0
 def test_groupby_other_methods_spotcheck(self, sample_data):
     rev = GrossRevenue(aligned_data=sample_data)
     rev.add_revenue_column()
     subdf = rev.subset_data(subset_on="peak")
     grouped = rev.group_data(subdf, [max, min, max, min])
     z = grouped.iloc[6, :]
     print(z)
     assert isclose(z[0], 9.530556, rel_tol=1e-04)
     assert isclose(z[1], 131.111105, rel_tol=1e-04)
     assert isclose(z[2], 43.969100, rel_tol=1e-04)
     assert isclose(z[3], 0.309022, rel_tol=1e-04)
Exemplo n.º 4
0
 def test_groupby_defaults_spotcheck(self, sample_data):
     rev = GrossRevenue(aligned_data=sample_data)
     rev.add_revenue_column()
     subdf = rev.subset_data(subset_on="peak")
     grouped = rev.group_data(subdf)
     z = grouped.iloc[6, :]
     print(z)
     assert isclose(z[0], 6.793248, rel_tol=1e-04)
     assert isclose(z[1], 1422.076282, rel_tol=1e-04)
     assert isclose(z[2], 10184.529100, rel_tol=1e-04)
     assert isclose(z[3], 1469.932431, rel_tol=1e-04)
Exemplo n.º 5
0
 def test_groupby_runs_other_methods(self, sample_data):
     rev = GrossRevenue(aligned_data=sample_data)
     rev.add_revenue_column()
     subdf = rev.subset_data(subset_on="peak")
     grouped = rev.group_data(subdf, [max, min, max, min])
     assert grouped.shape == (12, 4)