|
16 | 16 | from pandas.core.dtypes.cast import (
|
17 | 17 | maybe_downcast_to_dtype,
|
18 | 18 | maybe_convert_objects,
|
19 |
| - maybe_convert_for_categorical, |
20 | 19 | cast_scalar_to_array,
|
21 | 20 | infer_dtype_from_scalar,
|
22 | 21 | infer_dtype_from_array,
|
@@ -300,44 +299,6 @@ def test_maybe_infer_to_datetimelike(self):
|
300 | 299 | [NaT, 'b', 1]]))
|
301 | 300 | assert result.size == 6
|
302 | 301 |
|
303 |
| - def test_maybe_convert_for_categorical_noop(self): |
304 |
| - expected = ['1', '2'] |
305 |
| - result = maybe_convert_for_categorical(expected, None) |
306 |
| - assert result == expected |
307 |
| - |
308 |
| - result = maybe_convert_for_categorical(expected, CategoricalDtype()) |
309 |
| - assert result == expected |
310 |
| - |
311 |
| - result = maybe_convert_for_categorical(expected, 'category') |
312 |
| - assert result == expected |
313 |
| - |
314 |
| - @pytest.mark.parametrize('categories, dtype, expected', [ |
315 |
| - (['1', '2'], [1, 2, 3], np.array([1, 2], dtype='i8')), |
316 |
| - (['1', '2', 'a'], [1, 2, 3], np.array([1, 2, np.nan], dtype='f8')), |
317 |
| - ]) |
318 |
| - def test_maybe_convert_for_categorical(self, categories, dtype, expected): |
319 |
| - dtype = CategoricalDtype(dtype) |
320 |
| - result = maybe_convert_for_categorical(categories, dtype) |
321 |
| - tm.assert_numpy_array_equal(result, expected) |
322 |
| - |
323 |
| - @pytest.mark.parametrize('categories, dtype, expected', [ |
324 |
| - (['2016', '2017'], pd.to_datetime(['2016', '2017']), |
325 |
| - pd.to_datetime(['2016', '2017'])), |
326 |
| - (['2016', '2017', 'bad'], pd.to_datetime(['2016', '2017']), |
327 |
| - pd.to_datetime(['2016', '2017', 'NaT'])), |
328 |
| -
|
329 |
| - (['1H', '2H'], pd.to_timedelta(['1H', '2H']), |
330 |
| - pd.to_timedelta(['1H', '2H'])), |
331 |
| - (['1H', '2H', 'bad'], pd.to_timedelta(['1H', '2H']), |
332 |
| - pd.to_timedelta(['1H', '2H', 'NaT'])), |
333 |
| -
|
334 |
| - ]) |
335 |
| - def test_maybe_convert_for_categorical_dates(self, categories, dtype, |
336 |
| - expected): |
337 |
| - dtype = CategoricalDtype(dtype) |
338 |
| - result = maybe_convert_for_categorical(categories, dtype) |
339 |
| - tm.assert_index_equal(result, expected) |
340 |
| - |
341 | 302 |
|
342 | 303 | class TestConvert(object):
|
343 | 304 |
|
|
0 commit comments