Skip to content

Commit c3047f6

Browse files
committed
Resolving issue request pandas-dev#29738. Updated integer.py to analyze the types on iteratively going through the collection to cast to the appropriate type. In addition added a basic test case test_native_calls_types to assert that the change works
1 parent b9f26e2 commit c3047f6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pandas/core/arrays/integer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def __iter__(self):
450450
if self._mask[i]:
451451
yield self.dtype.na_value
452452
else:
453-
yield self._data[i]
453+
yield self._data[i].item()
454454

455455
def take(self, indexer, allow_fill=False, fill_value=None):
456456
# we always fill with 1 internally

pandas/tests/arrays/test_integer.py

+10
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,16 @@ def test_stat_method(pandasmethname, kwargs):
860860
expected = pandasmeth(**kwargs)
861861
assert expected == result
862862

863+
def test_native_calls_types():
864+
s = pd.Series([1, 2], dtype='int64')
865+
assert (type(list(s.iteritems())[0][1]) == type(1))
866+
assert(type(s[0]) != type(list(s.iteritems())[0][1]))
867+
s = pd.Series([1, 2], dtype='Int64')
868+
assert (type(list(s.iteritems())[0][1]) == type(1))
869+
870+
871+
872+
863873

864874
# TODO(jreback) - these need testing / are broken
865875

0 commit comments

Comments
 (0)