Skip to content

Commit 2853cb0

Browse files
authored
ARROW-155 Ensure compatibility with Pandas 2.0 (#139)
1 parent 2cd051e commit 2853cb0

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

bindings/python/pymongoarrow/pandas_types.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ def __arrow_array__(self, type=None):
229229

230230
return pa.array(self.data, type=BinaryType(self.dtype.subtype))
231231

232+
def __eq__(self, other):
233+
# Binary types do not support element-wise comparison.
234+
if isinstance(other, Binary):
235+
other = np.array(other, dtype=object)
236+
return super().__eq__(other)
237+
232238

233239
@register_extension_dtype
234240
class PandasObjectId(PandasBSONDtype):

bindings/python/setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ install_requires =
3737
# keep versions in sync with pyproject.toml "requires"
3838
pyarrow >=11.0,<11.1
3939
pymongo >=3.11,<5
40-
pandas >=1.3.5,<2
40+
pandas >=1.3.5,<3
4141

4242
[options.package_data]
4343
pymongoarrow = *.pxd, *.pyx, *.pyi, *.so.*, *.dylib, *.dll, *.pyd

bindings/python/test/test_pandas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def _create_data(self):
139139
schema = {k: v.to_pandas_dtype() for k, v in arrow_schema.items()}
140140
schema["Int64"] = pd.Int64Dtype()
141141
schema["int"] = pd.Int32Dtype()
142-
schema["str"] = "U8"
142+
schema["str"] = "string"
143143
schema["datetime"] = "datetime64[ns]"
144144

145145
data = pd.DataFrame(

0 commit comments

Comments
 (0)