def test_rename_excep(): d = { 'col1': [1, 2, 3, 4, 10], 'col2': [3, 4, 5, 6, 0], 'col3': ['q', '2', 'c', '4', 'x'] } f = Frame(d) names = f.colnames names.append('1') with pytest.raises(ValueError): f.rename(names)
def test_SetInput(): d = { 'col1': [1, 2, 3, 4.0, 10], 'col2': [3, 4, 5, 6, 0], 'col3': ['q', '2', 'c', '4', 'x'], 'date': ['05-09-1988', '22-12-1994', '21-11-1995', '22-06-1994', '12-12-2012'] } f = Frame(d) work = WorkbenchModelMock() # Set dataframe work.setDataframeByName('var', f) op = SetInput(work) assert op.getOutputShape() is None assert op.getOptions() == {'inputF': None} op.setOptions(inputF='var') op.addInputShape(Shape(), pos=0) # this does nothing assert op.getOptions() == {'inputF': 'var'} assert op.getOutputShape() == f.shape g = op.execute() assert g == f # g should be a copy f = f.rename({'col1': 'ewew'}) assert g != f
def test_rename_bis(): d = { 'col1': [1, 2, 3, 4, 10], 'col2': [3, 4, 5, 6, 0], 'col3': ['q', '2', 'c', '4', 'x'] } f = Frame(d) g = f.rename(['cola', '21eeds', 'ij_']) assert g.colnames == ['cola', '21eeds', 'ij_' ] and f.colnames == ['col1', 'col2', 'col3']
def test_rename(): d = { 'col1': [1, 2, 3, 4, 10], 'col2': [3, 4, 5, 6, 0], 'col3': ['q', '2', 'c', '4', 'x'] } f = Frame(d) g = f.rename({'col2': 'new'}) assert g.colnames == ['col1', 'new', 'col3' ] and f.colnames == ['col1', 'col2', 'col3']