Exemplo n.º 1
0
 def test_delete_single_column_number(self):
     result = render(
         pd.DataFrame({
             'A': [0, 0, 1],
             'B': ['monkey', 'kangaroo', 'cat']
         }), P(['A'], 'delete'))
     expected = pd.DataFrame({'A': [0, 1], 'B': ['monkey', 'cat']})
     assert_frame_equal(result, expected)
Exemplo n.º 2
0
 def test_delete_single_column_string(self):
     result = render(
         pd.DataFrame({
             'A': ['apple', 'apple', 'orange'],
             'B': ['monkey', 'kangaroo', 'cat'],
         }), P(['A'], 'delete'))
     expected = pd.DataFrame({
         'A': ['apple', 'orange'],
         'B': ['monkey', 'cat']
     })
     assert_frame_equal(result, expected)
Exemplo n.º 3
0
 def test_cumcount_single_column_number(self):
     result = render(
         pd.DataFrame({
             'A': [0, 0, 1],
             'B': ['monkey', 'kangaroo', 'cat']
         }), P(['A'], 'cumcount'))
     expected = pd.DataFrame({
         'A': [0, 0, 1],
         'B': ['monkey', 'kangaroo', 'cat'],
         'Duplicate number': [1, 2, 1]
     })
     assert_frame_equal(result, expected)
Exemplo n.º 4
0
 def test_delete_unused_categories(self):
     result = render(
         pd.DataFrame({
             'A': ['a', 'b', 'c'],
             'B': ['d', 'd', 'e']
         },
                      dtype='category'), P(['B'], 'delete'))
     expected = pd.DataFrame({
         'A': ['a', 'c'],
         'B': ['d', 'e']
     },
                             dtype='category')
     assert_frame_equal(result, expected)
Exemplo n.º 5
0
 def test_cumcount_multi_column(self):
     result = render(
         pd.DataFrame({
             'A': ['apple', 'orange', 'apple'],
             'B': [0, 'kangaroo', 0],
             'C': ['monkey', 'kangaroo', 'cat'],
         }), P(['A', 'B'], 'cumcount'))
     expected = pd.DataFrame({
         'A': ['apple', 'orange', 'apple'],
         'B': [0, 'kangaroo', 0],
         'C': ['monkey', 'kangaroo', 'cat'],
         'Duplicate number': [1, 1, 2]
     })
     assert_frame_equal(result, expected)
Exemplo n.º 6
0
 def test_no_colnames(self):
     # No colnames -> do nothing
     result = render(pd.DataFrame({'A': ['', np.nan, 'x']}), P([],
                                                               'delete'))
     expected = pd.DataFrame({'A': ['', np.nan, 'x']})
     assert_frame_equal(result, expected)