Skip to content

Commit

Permalink
GH34529
Browse files Browse the repository at this point in the history
correction and test for issue-pandas-dev#34529

made the formating changes
  • Loading branch information
Veronur committed Jun 16, 2020
1 parent 6258397 commit 685b3c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ def construct_1d_ndarray_preserving_na(
"""
subarr = np.array(values, dtype=dtype, copy=copy)

if dtype is not None and dtype.kind in ("U", "S"):
if dtype is not None and dtype.kind == "U":
# GH-21083
# We can't just return np.array(subarr, dtype='str') since
# NumPy will convert the non-string objects into strings
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/frame/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,14 @@ def non_reducing_function(val):
df.applymap(func)
assert values == df.a.to_list()

def test_apply_with_byte_string(self):
# GH 34529
try:
df = pd.DataFrame(np.array([b"abcd", b"efgh"]), columns=["col"])
df.apply(lambda x: x.astype("object"))
except OSError as err:
tm.external_error_raised(err)


class TestInferOutputShape:
# the user has supplied an opaque UDF where
Expand Down

0 comments on commit 685b3c5

Please sign in to comment.