Skip to content

Commit 50118d7

Browse files
committed
Add getattr as other might not possess attrs as attribute
1 parent 15db834 commit 50118d7

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

pandas/core/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ def _arith_method(self, other, op):
14661466
with np.errstate(all="ignore"):
14671467
result = ops.arithmetic_op(lvalues, rvalues, op)
14681468

1469-
if not self.attrs and other.attrs:
1469+
if not getattr(self, "attrs", None) and getattr(other, "attrs", None):
14701470
self.attrs = other.attrs
14711471

14721472
return self._construct_result(result, name=res_name)

pandas/core/frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7831,7 +7831,7 @@ def _arith_method(self, other, op):
78317831
with np.errstate(all="ignore"):
78327832
new_data = self._dispatch_frame_op(other, op, axis=axis)
78337833

7834-
if not self.attrs and other.attrs:
7834+
if not getattr(self, "attrs", None) and getattr(other, "attrs", None):
78357835
self.attrs = other.attrs
78367836

78377837
return self._construct_result(new_data)
@@ -8189,7 +8189,7 @@ def _flex_arith_method(
81898189

81908190
new_data = self._dispatch_frame_op(other, op)
81918191

8192-
if not self.attrs and other.attrs:
8192+
if not getattr(self, "attrs", None) and getattr(other, "attrs", None):
81938193
self.attrs = other.attrs
81948194

81958195
return self._construct_result(new_data)

pandas/core/series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5917,7 +5917,7 @@ def _binop(self, other: Series, func, level=None, fill_value=None) -> Series:
59175917

59185918
name = ops.get_op_result_name(self, other)
59195919

5920-
if not this.attrs and other.attrs:
5920+
if not getattr(this, "attrs", None) and getattr(other, "attrs", None):
59215921
this.attrs = other.attrs
59225922

59235923
out = this._construct_result(result, name)

0 commit comments

Comments
 (0)