Skip to content

Commit 4ab85ef

Browse files
author
Veronur
committed
GH34529
correction and test for issue-pandas-dev#34529
1 parent 6258397 commit 4ab85ef

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-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

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

788+
<<<<<<< HEAD
789+
=======
790+
def test_apply_with_byte_string(self):
791+
# GH 34529
792+
try:
793+
df = pd.DataFrame(np.array([b'abcd', b'efgh']), columns=['col'])
794+
df.apply(lambda x: x.astype('object'))
795+
except OSError as err:
796+
tm.external_error_raised(err)
797+
>>>>>>> 3cc40f2cf... correction on test for issue-#34529
788798

789799
class TestInferOutputShape:
790800
# the user has supplied an opaque UDF where

0 commit comments

Comments
 (0)