Skip to content

Commit d598002

Browse files
author
Patrick Leonardy
committed
added example 4 categorical in test_drops_columns_containing_only_nan
1 parent 6f09fd2 commit d598002

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

tests/preprocessing/test_preprocessor.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,56 @@ def test_mutable_train_data_fit_transform(self, mocker: MockerFixture):
254254
}
255255
),
256256
),
257+
# example 4 categorical
258+
(
259+
pd.DataFrame(
260+
{
261+
"a": [1, 8, np.nan],
262+
"b": [np.nan, np.nan, np.nan],
263+
"d": [np.nan, np.nan, 5],
264+
"e": [1, 960, np.nan],
265+
"category_1": ["A", "A", "B"],
266+
"category_2": [np.nan, "A", "B"],
267+
"category_3": [np.nan, np.nan, np.nan],
268+
},
269+
).astype(
270+
{
271+
"a": np.float64(),
272+
"b": np.float64(),
273+
"d": np.float64(),
274+
"e": np.float64(),
275+
"category_1": pd.CategoricalDtype(),
276+
"category_2": pd.CategoricalDtype(),
277+
"category_3": pd.CategoricalDtype(),
278+
}
279+
),
280+
pd.DataFrame(
281+
{
282+
"a": [1, 8, np.nan],
283+
"d": [np.nan, np.nan, 5],
284+
"e": [1, 960, np.nan],
285+
"category_1": ["A", "A", "B"],
286+
"category_2": [np.nan, "A", "B"],
287+
}
288+
).astype(
289+
{
290+
"a": np.float64(),
291+
"d": np.float64(),
292+
"e": np.float64(),
293+
"category_1": pd.CategoricalDtype(),
294+
"category_2": pd.CategoricalDtype(),
295+
}
296+
),
297+
),
257298
],
258299
)
259300
def test_drops_columns_containing_only_nan(self, input, expected):
260301

302+
print(input)
261303
output = PreProcessor._check_nan_columns_and_drop_columns_containing_only_nan(
262304
input
263305
)
306+
307+
print(output)
308+
print(expected)
264309
assert output.equals(expected)

0 commit comments

Comments
 (0)