Skip to content

BUG: Merge with readonly arrays #27946

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

Merged
merged 1 commit into from
Aug 16, 2019
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
4 changes: 2 additions & 2 deletions doc/source/whatsnew/v0.25.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ Reshaping
^^^^^^^^^

- A ``KeyError`` is now raised if ``.unstack()`` is called on a :class:`Series` or :class:`DataFrame` with a flat :class:`Index` passing a name which is not the correct one (:issue:`18303`)
- Bug in :meth:`DataFrame.crosstab` when ``margins`` set to ``True`` and ``normalize`` is not ``False``, an error is raised. (:issue:`27500`)
- Bug in :meth:`DataFrame.crosstab` when ``margins`` set to ``True`` and ``normalize`` is not ``False``, an error is raised. (:issue:`27500`)
- :meth:`DataFrame.join` now suppresses the ``FutureWarning`` when the sort parameter is specified (:issue:`21952`)
-
- Bug in :meth:`DataFrame.join` raising with readonly arrays (:issue:`27943`)

Sparse
^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/hashtable.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ cdef class Int64Factorizer:
def get_count(self):
return self.count

def factorize(self, int64_t[:] values, sort=False,
def factorize(self, const int64_t[:] values, sort=False,
na_sentinel=-1, na_value=None):
"""
Factorize values with nans replaced by na_sentinel
Expand Down
12 changes: 12 additions & 0 deletions pandas/tests/reshape/merge/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,18 @@ def test_merge_take_missing_values_from_index_of_other_dtype(self):
expected = expected.reindex(columns=["a", "key", "b"])
tm.assert_frame_equal(result, expected)

def test_merge_readonly(self):
# https://github.com/pandas-dev/pandas/issues/27943
data1 = pd.DataFrame(
np.arange(20).reshape((4, 5)) + 1, columns=["a", "b", "c", "d", "e"]
)
data2 = pd.DataFrame(
np.arange(20).reshape((5, 4)) + 1, columns=["a", "b", "x", "y"]
)

data1._data.blocks[0].values.flags.writeable = False
data1.merge(data2) # no error


def _check_merge(x, y):
for how in ["inner", "left", "outer"]:
Expand Down