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

fixing tests on issue-pandas-dev#34529

add whats new entry on issue-pandas-dev#34539

add whats new entry correction issue-pandas-dev#34539
  • Loading branch information
Veronur committed Jun 17, 2020
1 parent 6258397 commit fb7ad08
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@ ExtensionArray
- Fixed bug where :meth:`StringArray.memory_usage` was not implemented (:issue:`33963`)
- Fixed bug where :meth:`DataFrameGroupBy` would ignore the ``min_count`` argument for aggregations on nullable boolean dtypes (:issue:`34051`)
- Fixed bug that `DataFrame(columns=.., dtype='string')` would fail (:issue:`27953`, :issue:`33623`)
- Fixed regression where :meth:`DataFrame.apply` would raise ``ValueError`` for elements whth ``S`` dtype (:issue:`34529`)

Other
^^^^^
Expand Down
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
11 changes: 11 additions & 0 deletions pandas/tests/frame/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,17 @@ def non_reducing_function(val):
df.applymap(func)
assert values == df.a.to_list()

def test_apply_with_byte_string(self):
# GH 34529
df = pd.DataFrame(np.array([b"abcd", b"efgh"]), columns=["col"])
expected = pd.DataFrame(
np.array([b"abcd", b"efgh"]), columns=["col"], dtype=object
)
# After we make the aply we exect a dataframe just
# like the original but with the object datatype
result = df.apply(lambda x: x.astype("object"))
tm.assert_frame_equal(result, expected)


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

0 comments on commit fb7ad08

Please sign in to comment.