Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Series[EA].astype(str) works #20581

Merged
merged 1 commit into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ def _astype(self, dtype, copy=False, errors='raise', values=None,

# astype formatting
else:
values = self.values
values = self.get_values()

else:
values = self.get_values(dtype=dtype)
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/extension/base/casting.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ def test_tolist(self, data):
result = pd.Series(data).tolist()
expected = list(data)
assert result == expected

def test_astype_str(self, data):
result = pd.Series(data[:5]).astype(str)
expected = pd.Series(data[:5].astype(str))
self.assert_series_equal(result, expected)
7 changes: 6 additions & 1 deletion pandas/tests/extension/json/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ def test_sort_values_missing(self, data_missing_for_sorting, ascending):


class TestCasting(base.BaseCastingTests):
pass
@pytest.mark.xfail
def test_astype_str(self):
"""This currently fails in NumPy on np.array(self, dtype=str) with

*** ValueError: setting an array element with a sequence
"""


class TestGroupby(base.BaseGroupbyTests):
Expand Down