Skip to content

Commit c785fb8

Browse files
TomAugspurgerMeeseeksDev[bot]
authored and
MeeseeksDev[bot]
committed
Backport PR pandas-dev#27946: BUG: Merge with readonly arrays
1 parent 095c26f commit c785fb8

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

doc/source/whatsnew/v0.25.1.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ Reshaping
127127
^^^^^^^^^
128128

129129
- 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`)
130-
- Bug in :meth:`DataFrame.crosstab` when ``margins`` set to ``True`` and ``normalize`` is not ``False``, an error is raised. (:issue:`27500`)
130+
- Bug in :meth:`DataFrame.crosstab` when ``margins`` set to ``True`` and ``normalize`` is not ``False``, an error is raised. (:issue:`27500`)
131131
- :meth:`DataFrame.join` now suppresses the ``FutureWarning`` when the sort parameter is specified (:issue:`21952`)
132-
-
132+
- Bug in :meth:`DataFrame.join` raising with readonly arrays (:issue:`27943`)
133133

134134
Sparse
135135
^^^^^^

pandas/_libs/hashtable.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ cdef class Int64Factorizer:
108108
def get_count(self):
109109
return self.count
110110

111-
def factorize(self, int64_t[:] values, sort=False,
111+
def factorize(self, const int64_t[:] values, sort=False,
112112
na_sentinel=-1, na_value=None):
113113
"""
114114
Factorize values with nans replaced by na_sentinel

pandas/tests/reshape/merge/test_merge.py

+12
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,18 @@ def test_merge_take_missing_values_from_index_of_other_dtype(self):
13401340
expected = expected.reindex(columns=["a", "key", "b"])
13411341
tm.assert_frame_equal(result, expected)
13421342

1343+
def test_merge_readonly(self):
1344+
# https://github.com/pandas-dev/pandas/issues/27943
1345+
data1 = pd.DataFrame(
1346+
np.arange(20).reshape((4, 5)) + 1, columns=["a", "b", "c", "d", "e"]
1347+
)
1348+
data2 = pd.DataFrame(
1349+
np.arange(20).reshape((5, 4)) + 1, columns=["a", "b", "x", "y"]
1350+
)
1351+
1352+
data1._data.blocks[0].values.flags.writeable = False
1353+
data1.merge(data2) # no error
1354+
13431355

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

0 commit comments

Comments
 (0)