Skip to content

Commit

Permalink
Resolving issue request pandas-dev#29738. Updated integer.py to analy…
Browse files Browse the repository at this point in the history
…ze 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
  • Loading branch information
Brosinc132 committed Dec 10, 2019
1 parent b9f26e2 commit c3047f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pandas/core/arrays/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def __iter__(self):
if self._mask[i]:
yield self.dtype.na_value
else:
yield self._data[i]
yield self._data[i].item()

def take(self, indexer, allow_fill=False, fill_value=None):
# we always fill with 1 internally
Expand Down
10 changes: 10 additions & 0 deletions pandas/tests/arrays/test_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,16 @@ def test_stat_method(pandasmethname, kwargs):
expected = pandasmeth(**kwargs)
assert expected == result

def test_native_calls_types():
s = pd.Series([1, 2], dtype='int64')
assert (type(list(s.iteritems())[0][1]) == type(1))
assert(type(s[0]) != type(list(s.iteritems())[0][1]))
s = pd.Series([1, 2], dtype='Int64')
assert (type(list(s.iteritems())[0][1]) == type(1))





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

Expand Down

1 comment on commit c3047f6

@bajacc
Copy link

@bajacc bajacc commented on c3047f6 Dec 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code reviewed. You should add more comments to explain the assert in test_native_calls_types(). You should also be more general on the pq.Series dtype.

Please sign in to comment.