From 0e8c3f875de3ac39a56e0864ecfc220b4ad8dd2e Mon Sep 17 00:00:00 2001 From: lrjball <50599110+lrjball@users.noreply.github.com> Date: Tue, 3 Mar 2020 22:28:36 +0000 Subject: [PATCH 1/2] Fixed test so that whole test isn't skipped if pandas not installed As raised by @thomasjpfan in #14048, the remainder of the test will be skipped if pandas is not installed. This has been fixed in this PR by separating the test into two functions, on for arrays and one for dataframes. --- sklearn/compose/tests/test_column_transformer.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sklearn/compose/tests/test_column_transformer.py b/sklearn/compose/tests/test_column_transformer.py index 13a25b0ec0493..e433b71e9f59a 100644 --- a/sklearn/compose/tests/test_column_transformer.py +++ b/sklearn/compose/tests/test_column_transformer.py @@ -1021,7 +1021,7 @@ def test_column_transformer_no_estimators_set_params(): def test_column_transformer_callable_specifier(): - # assert that function gets the full array / dataframe + # assert that function gets the full array X_array = np.array([[0, 1, 2], [2, 4, 6]]).T X_res_first = np.array([[0, 1, 2]]).T @@ -1036,7 +1036,13 @@ def func(X): assert callable(ct.transformers[0][2]) assert ct.transformers_[0][2] == [0] + +def test_column_transformer_callable_specifier_dataframe(): + # assert that function gets the full dataframe pd = pytest.importorskip('pandas') + X_array = np.array([[0, 1, 2], [2, 4, 6]]).T + X_res_first = np.array([[0, 1, 2]]).T + X_df = pd.DataFrame(X_array, columns=['first', 'second']) def func(X): From 29431cbad00ee678bd172698422227869161eedf Mon Sep 17 00:00:00 2001 From: lrjball <50599110+lrjball@users.noreply.github.com> Date: Tue, 3 Mar 2020 22:28:36 +0000 Subject: [PATCH 2/2] Fixed test so that whole test isn't skipped if pandas not installed As raised by @thomasjpfan in #14048, the remainder of the test will be skipped if pandas is not installed. This has been fixed in this PR by separating the test into two functions, on for arrays and one for dataframes. --- sklearn/compose/tests/test_column_transformer.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sklearn/compose/tests/test_column_transformer.py b/sklearn/compose/tests/test_column_transformer.py index d26f6895427bb..ca1c185c91e06 100644 --- a/sklearn/compose/tests/test_column_transformer.py +++ b/sklearn/compose/tests/test_column_transformer.py @@ -1040,7 +1040,7 @@ def test_column_transformer_no_estimators_set_params(): def test_column_transformer_callable_specifier(): - # assert that function gets the full array / dataframe + # assert that function gets the full array X_array = np.array([[0, 1, 2], [2, 4, 6]]).T X_res_first = np.array([[0, 1, 2]]).T @@ -1055,7 +1055,13 @@ def func(X): assert callable(ct.transformers[0][2]) assert ct.transformers_[0][2] == [0] + +def test_column_transformer_callable_specifier_dataframe(): + # assert that function gets the full dataframe pd = pytest.importorskip('pandas') + X_array = np.array([[0, 1, 2], [2, 4, 6]]).T + X_res_first = np.array([[0, 1, 2]]).T + X_df = pd.DataFrame(X_array, columns=['first', 'second']) def func(X):