def test_group_rename(self): foo = TimeSeries({ 1: 2, 3: 4 }) bar = TimeSeries({ 5: 6, 7: 8 }) group = DataFrame(foo=foo, bar=bar) group.rename(foo='Foo Bar') self.assertFalse('foo' in group) self.assertTrue('Foo Bar' in group)
def test_linear_trend(self): foo = TimeSeries([ (1, 32), (2, 55), (3, 40) ]) bar = TimeSeries([ (4, 42), (5, 65), (6, 50) ]) group = DataFrame(foo=foo, bar=bar) trend = group.trend().round() self.assertListEqual(trend['foo'].timestamps, [1, 2, 3]) self.assertListEqual(trend['foo'].values, [38, 42, 46]) self.assertListEqual(trend['bar'].timestamps, [4, 5, 6]) self.assertListEqual(trend['bar'].values, [48, 52, 56])
def test_group_accessors(self): foo = TimeSeries({ 1: 2, 3: 4 }) bar = TimeSeries({ 5: 6, 7: 8 }) group = DataFrame(foo=foo, bar=bar) self.assertIs(foo, group['foo']) self.assertIs(bar, group['bar']) self.assertIs(foo, group.foo) self.assertIs(bar, group.bar) self.assertEquals(len(group), 2) del group['foo'] self.assertEquals(len(group), 1) group['foo'] = foo self.assertEquals(len(group), 2) self.assertIs(foo, group['foo']) self.assertListEqual(group.items(), [ ('foo', foo), ('bar', bar) ])
def test_group_abs(self): a = TimeSeries([ (1, -1), (2, -3), (3, 3.3) ]) group = DataFrame(a=a) group = abs(group) self.assertListEqual(group['a'].values, [ 1, 3, 3.3 ])
def test_group_timestamps(self): a = TimeSeries([ (1, 3), (2, 3), (3, 3) ]) b = TimeSeries([ (0, 2), (1, 3), (2, 2), (3, 1), (4, 1) ]) c = TimeSeries([ (5, 1), (6, 1) ]) group = DataFrame(a=a, b=b, c=c) self.assertListEqual(group.timestamps, [ 0, 1, 2, 3, 4, 5, 6 ])