16
16
option_context ,
17
17
)
18
18
import pandas ._testing as tm
19
- from pandas .core .arrays import IntervalArray , integer_array
20
19
from pandas .core .internals import ObjectBlock
21
20
from pandas .core .internals .blocks import IntBlock
22
21
@@ -306,73 +305,6 @@ def test_is_mixed_type(self, float_frame, float_string_frame):
306
305
assert not float_frame ._is_mixed_type
307
306
assert float_string_frame ._is_mixed_type
308
307
309
- def test_get_numeric_data (self ):
310
-
311
- datetime64name = np .dtype ("M8[ns]" ).name
312
- objectname = np .dtype (np .object_ ).name
313
-
314
- df = DataFrame (
315
- {"a" : 1.0 , "b" : 2 , "c" : "foo" , "f" : Timestamp ("20010102" )},
316
- index = np .arange (10 ),
317
- )
318
- result = df .dtypes
319
- expected = Series (
320
- [
321
- np .dtype ("float64" ),
322
- np .dtype ("int64" ),
323
- np .dtype (objectname ),
324
- np .dtype (datetime64name ),
325
- ],
326
- index = ["a" , "b" , "c" , "f" ],
327
- )
328
- tm .assert_series_equal (result , expected )
329
-
330
- df = DataFrame (
331
- {
332
- "a" : 1.0 ,
333
- "b" : 2 ,
334
- "c" : "foo" ,
335
- "d" : np .array ([1.0 ] * 10 , dtype = "float32" ),
336
- "e" : np .array ([1 ] * 10 , dtype = "int32" ),
337
- "f" : np .array ([1 ] * 10 , dtype = "int16" ),
338
- "g" : Timestamp ("20010102" ),
339
- },
340
- index = np .arange (10 ),
341
- )
342
-
343
- result = df ._get_numeric_data ()
344
- expected = df .loc [:, ["a" , "b" , "d" , "e" , "f" ]]
345
- tm .assert_frame_equal (result , expected )
346
-
347
- only_obj = df .loc [:, ["c" , "g" ]]
348
- result = only_obj ._get_numeric_data ()
349
- expected = df .loc [:, []]
350
- tm .assert_frame_equal (result , expected )
351
-
352
- df = DataFrame .from_dict ({"a" : [1 , 2 ], "b" : ["foo" , "bar" ], "c" : [np .pi , np .e ]})
353
- result = df ._get_numeric_data ()
354
- expected = DataFrame .from_dict ({"a" : [1 , 2 ], "c" : [np .pi , np .e ]})
355
- tm .assert_frame_equal (result , expected )
356
-
357
- df = result .copy ()
358
- result = df ._get_numeric_data ()
359
- expected = df
360
- tm .assert_frame_equal (result , expected )
361
-
362
- def test_get_numeric_data_extension_dtype (self ):
363
- # GH 22290
364
- df = DataFrame (
365
- {
366
- "A" : integer_array ([- 10 , np .nan , 0 , 10 , 20 , 30 ], dtype = "Int64" ),
367
- "B" : Categorical (list ("abcabc" )),
368
- "C" : integer_array ([0 , 1 , 2 , 3 , np .nan , 5 ], dtype = "UInt8" ),
369
- "D" : IntervalArray .from_breaks (range (7 )),
370
- }
371
- )
372
- result = df ._get_numeric_data ()
373
- expected = df .loc [:, ["A" , "C" ]]
374
- tm .assert_frame_equal (result , expected )
375
-
376
308
def test_stale_cached_series_bug_473 (self ):
377
309
378
310
# this is chained, but ok
@@ -390,21 +322,6 @@ def test_stale_cached_series_bug_473(self):
390
322
exp = Y ["g" ].sum () # noqa
391
323
assert pd .isna (Y ["g" ]["c" ])
392
324
393
- def test_get_X_columns (self ):
394
- # numeric and object columns
395
-
396
- df = DataFrame (
397
- {
398
- "a" : [1 , 2 , 3 ],
399
- "b" : [True , False , True ],
400
- "c" : ["foo" , "bar" , "baz" ],
401
- "d" : [None , None , None ],
402
- "e" : [3.14 , 0.577 , 2.773 ],
403
- }
404
- )
405
-
406
- tm .assert_index_equal (df ._get_numeric_data ().columns , pd .Index (["a" , "b" , "e" ]))
407
-
408
325
def test_strange_column_corruption_issue (self ):
409
326
# FIXME: dont leave commented-out
410
327
# (wesm) Unclear how exactly this is related to internal matters
@@ -458,7 +375,7 @@ def test_update_inplace_sets_valid_block_values():
458
375
df ["a" ].fillna (1 , inplace = True )
459
376
460
377
# check we havent put a Series into any block.values
461
- assert isinstance (df ._mgr .blocks [0 ].values , pd . Categorical )
378
+ assert isinstance (df ._mgr .blocks [0 ].values , Categorical )
462
379
463
380
# smoketest for OP bug from GH#35731
464
381
assert df .isnull ().sum ().sum () == 0
0 commit comments