Skip to content

Commit 685b3c5

Browse files
author
Veronur
committed
GH34529
correction and test for issue-pandas-dev#34529 made the formating changes
1 parent 6258397 commit 685b3c5

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pandas/core/dtypes/cast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ def construct_1d_ndarray_preserving_na(
16081608
"""
16091609
subarr = np.array(values, dtype=dtype, copy=copy)
16101610

1611-
if dtype is not None and dtype.kind in ("U", "S"):
1611+
if dtype is not None and dtype.kind == "U":
16121612
# GH-21083
16131613
# We can't just return np.array(subarr, dtype='str') since
16141614
# NumPy will convert the non-string objects into strings

pandas/tests/frame/test_apply.py

+8
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,14 @@ def non_reducing_function(val):
785785
df.applymap(func)
786786
assert values == df.a.to_list()
787787

788+
def test_apply_with_byte_string(self):
789+
# GH 34529
790+
try:
791+
df = pd.DataFrame(np.array([b"abcd", b"efgh"]), columns=["col"])
792+
df.apply(lambda x: x.astype("object"))
793+
except OSError as err:
794+
tm.external_error_raised(err)
795+
788796

789797
class TestInferOutputShape:
790798
# the user has supplied an opaque UDF where

0 commit comments

Comments
 (0)