File tree Expand file tree Collapse file tree 4 files changed +15
-6
lines changed Expand file tree Collapse file tree 4 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -260,6 +260,8 @@ See :ref:`Internal Refactoring<whatsnew_0130.refactoring>`
260
260
- Fix bug in ``pd.read_clipboard `` on windows with PY3 (:issue: `4561 `); not decoding properly
261
261
- ``tslib.get_period_field() `` and ``tslib.get_period_field_arr() `` now raise
262
262
if code argument out of range (:issue: `4519 `, :issue: `4520 `)
263
+ - Fix boolean indexing on an empty series loses index names (:issue: `4235 `),
264
+ infer_dtype works with empty arrays.
263
265
- Fix reindexing with multiple axes; if an axes match was not replacing the current axes, leading
264
266
to a possible lazay frequency inference issue (:issue: `3317 `)
265
267
- Fixed issue where ``DataFrame.apply `` was reraising exceptions incorrectly
Original file line number Diff line number Diff line change @@ -41,17 +41,17 @@ def infer_dtype(object _values):
41
41
_values = list (_values)
42
42
values = list_to_object_array(_values)
43
43
44
- n = len (values)
45
- if n == 0 :
46
- return ' empty'
47
-
48
44
val_kind = values.dtype.type
49
45
if val_kind in _TYPE_MAP:
50
46
return _TYPE_MAP[val_kind]
51
47
52
48
if values.dtype != np.object_:
53
49
values = values.astype(' O' )
54
50
51
+ n = len (values)
52
+ if n == 0 :
53
+ return ' empty'
54
+
55
55
val = util.get_value_1d(values, 0 )
56
56
57
57
if util.is_datetime64_object(val):
Original file line number Diff line number Diff line change @@ -740,6 +740,13 @@ def test_getitem_boolean(self):
740
740
assert_series_equal (result , expected )
741
741
self .assert_ (np .array_equal (result .index , s .index [mask ]))
742
742
743
+ def test_getitem_boolean_empty (self ):
744
+ s = Series ([], dtype = np .int64 )
745
+ s .index .name = 'index_name'
746
+ s = s [s .isnull ()]
747
+ self .assertEqual (s .index .name , 'index_name' )
748
+ self .assertEqual (s .dtype , np .int64 )
749
+
743
750
def test_getitem_generator (self ):
744
751
gen = (x > 0 for x in self .series )
745
752
result = self .series [gen ]
Original file line number Diff line number Diff line change @@ -565,9 +565,9 @@ class TestTypeInference(unittest.TestCase):
565
565
566
566
def test_length_zero (self ):
567
567
result = lib .infer_dtype (np .array ([], dtype = 'i4' ))
568
- self .assertEqual (result , 'empty ' )
568
+ self .assertEqual (result , 'integer ' )
569
569
570
- result = lib .infer_dtype (np . array ([], dtype = 'O' ) )
570
+ result = lib .infer_dtype ([] )
571
571
self .assertEqual (result , 'empty' )
572
572
573
573
def test_integers (self ):
You can’t perform that action at this time.
0 commit comments