Skip to content

Commit 4ddfa93

Browse files
committed
BUG: GH38801 avoid attribute error with pyarrow >=0.16.0 and <1.0.0
1 parent f58d815 commit 4ddfa93

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

pandas/core/arrays/string_arrow.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,20 @@
3636
except ImportError:
3737
pass
3838
else:
39-
ARROW_CMP_FUNCS = {
40-
"eq": pc.equal,
41-
"ne": pc.not_equal,
42-
"lt": pc.less,
43-
"gt": pc.greater,
44-
"le": pc.less_equal,
45-
"ge": pc.greater_equal,
46-
}
39+
# pyarrow 0.16.0 adds a compute module (thus the above compute import
40+
# will work) but the attributes below are not available until pyarrow
41+
# 1.0.0 resulting in an Attribute Error with pyarrow (0.16.0, 1.0.0].
42+
try:
43+
ARROW_CMP_FUNCS = {
44+
"eq": pc.equal,
45+
"ne": pc.not_equal,
46+
"lt": pc.less,
47+
"gt": pc.greater,
48+
"le": pc.less_equal,
49+
"ge": pc.greater_equal,
50+
}
51+
except AttributeError:
52+
pass
4753

4854

4955
if TYPE_CHECKING:

0 commit comments

Comments
 (0)