Example #1
0
 def test_offset_2parts_1(self):
     """pseudo-random, many parts"""
     temp1 = [
         pandas.Series([
             'd', 'd', 'a', 's', 's', 'd', 'f', 'a', 'f', 'f', 's', 'd',
             'f', 's', 'f', 'd', 's', 's', 'a', 's'
         ],
                       index=range(1, 21))
     ] * 2
     in_val = pandas.concat(temp1, axis=1)
     in_val.columns = pandas.MultiIndex.from_product([('A', ), ('0', '1')])
     temp2 = [
         pandas.Series([
             'd', 'a', 's', 'd', 'f', 'a', 'f', 's', 'd', 'f', 's', 'f',
             'd', 's', 'a', 's'
         ],
                       index=[
                           1, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17,
                           19, 20
                       ]),
         pandas.Series([
             'd', 'a', 's', 'd', 'f', 'a', 'f', 's', 'd', 'f', 's', 'f',
             'd', 's', 'a', 's'
         ],
                       index=[
                           1, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17,
                           19, 20
                       ])
     ]
     expected = pandas.concat(temp2, axis=1)
     actual = FilterByRepeatIndexer(in_val).run()
     expected.columns = actual.columns
     self.assertTrue(actual.equals(expected))
Example #2
0
 def test_offset_1part_6(self):
     """pseudo-random"""
     in_val = [
         pandas.Series([
             'd', 'd', 'a', 's', 's', 'd', 'f', 'a', 'f', 'f', 's', 'd',
             'f', 's', 'f', 'd', 's', 's', 'a', 's'
         ],
                       index=[
                           1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
                           15, 16, 17, 18, 19, 20
                       ])
     ]
     in_val = pandas.concat(in_val, axis=1)
     in_val.columns = pandas.MultiIndex.from_product([('A', ), ('0', )])
     expected = [
         pandas.Series([
             'd', 'a', 's', 'd', 'f', 'a', 'f', 's', 'd', 'f', 's', 'f',
             'd', 's', 'a', 's'
         ],
                       index=[
                           1, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17,
                           19, 20
                       ])
     ]
     expected = pandas.concat(expected, axis=1)
     actual = FilterByRepeatIndexer(in_val).run()
     expected.columns = actual.columns
     self.assertTrue(actual.equals(expected))
Example #3
0
 def test_offset_1part_1a(self):
     """1 part with 0 length"""
     in_val = [pandas.Series()]
     expected = [pandas.Series()]
     in_val = pandas.concat(in_val, axis=1)
     in_val.columns = pandas.MultiIndex.from_product([('A', ), ('0', )])
     expected = pandas.concat(expected, axis=1)
     actual = FilterByRepeatIndexer(in_val).run()
     expected.columns = actual.columns
     self.assertTrue(actual.equals(expected))
Example #4
0
 def test_offset_1part_2(self):
     """input is expected output"""
     in_val = [
         pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5])
     ]
     expected = [
         pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5])
     ]
     in_val = pandas.concat(in_val, axis=1)
     in_val.columns = pandas.MultiIndex.from_product([('A', ), ('0', )])
     expected = pandas.concat(expected, axis=1)
     actual = FilterByRepeatIndexer(in_val).run()
     expected.columns = actual.columns
     self.assertTrue(actual.equals(expected))
Example #5
0
 def test_offset_1part_1b(self):
     """2 parts, one of which has 0 length"""
     in_val = [
         pandas.Series(),
         pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5])
     ]
     expected = [
         pandas.Series([nan, nan, nan, nan], index=[0.0, 0.5, 1.0, 1.5]),
         pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5])
     ]
     in_val = pandas.concat(in_val, axis=1)
     in_val.columns = pandas.MultiIndex.from_product([('A', ), ('0', '1')])
     expected = pandas.concat(expected, axis=1)
     actual = FilterByRepeatIndexer(in_val).run()
     expected.columns = actual.columns
     self.assertTrue(actual.equals(expected))