|
15 | 15 | from pandas.core.generic import AxisProperty, NDFrame |
16 | 16 | from pandas.core.series import Series |
17 | 17 | from pandas.util.decorators import deprecate |
| 18 | +from pandas.util import py3compat |
18 | 19 | import pandas.core.common as common |
19 | 20 | import pandas._tseries as _tseries |
20 | 21 |
|
@@ -170,16 +171,22 @@ class Panel(NDFrame): |
170 | 171 |
|
171 | 172 | __add__ = _arith_method(operator.add, '__add__') |
172 | 173 | __sub__ = _arith_method(operator.sub, '__sub__') |
| 174 | + __truediv__ = _arith_method(operator.truediv, '__truediv__') |
| 175 | + __floordiv__ = _arith_method(operator.floordiv, '__floordiv__') |
173 | 176 | __mul__ = _arith_method(operator.mul, '__mul__') |
174 | | - __div__ = _arith_method(operator.div, '__div__') |
175 | 177 | __pow__ = _arith_method(operator.pow, '__pow__') |
176 | 178 |
|
177 | 179 | __radd__ = _arith_method(operator.add, '__radd__') |
178 | 180 | __rmul__ = _arith_method(operator.mul, '__rmul__') |
179 | 181 | __rsub__ = _arith_method(lambda x, y: y - x, '__rsub__') |
180 | | - __rdiv__ = _arith_method(lambda x, y: y / x, '__rdiv__') |
| 182 | + __rtruediv__ = _arith_method(lambda x, y: y / x, '__rtruediv__') |
| 183 | + __rfloordiv__ = _arith_method(lambda x, y: y // x, '__rfloordiv__') |
181 | 184 | __rpow__ = _arith_method(lambda x, y: y ** x, '__rpow__') |
182 | 185 |
|
| 186 | + if not py3compat.PY3: |
| 187 | + __div__ = _arith_method(operator.div, '__div__') |
| 188 | + __rdiv__ = _arith_method(lambda x, y: y / x, '__rdiv__') |
| 189 | + |
183 | 190 | def __init__(self, data, items=None, major_axis=None, minor_axis=None, |
184 | 191 | copy=False, dtype=None): |
185 | 192 | """ |
@@ -642,8 +649,12 @@ def fillna(self, value=None, method='pad'): |
642 | 649 |
|
643 | 650 | add = _panel_arith_method(operator.add, 'add') |
644 | 651 | subtract = sub = _panel_arith_method(operator.sub, 'subtract') |
645 | | - divide = div = _panel_arith_method(operator.div, 'divide') |
646 | 652 | multiply = mul = _panel_arith_method(operator.mul, 'multiply') |
| 653 | + |
| 654 | + try: |
| 655 | + divide = div = _panel_arith_method(operator.div, 'divide') |
| 656 | + except AttributeError: # Python 3 |
| 657 | + divide = div = _panel_arith_method(operator.truediv, 'divide') |
647 | 658 |
|
648 | 659 | def major_xs(self, key, copy=True): |
649 | 660 | """ |
@@ -1214,8 +1225,12 @@ def _combine_panel_frame(self, other, func, axis='items'): |
1214 | 1225 |
|
1215 | 1226 | add = _panel_arith_method(operator.add, 'add') |
1216 | 1227 | subtract = sub = _panel_arith_method(operator.sub, 'subtract') |
1217 | | - divide = div = _panel_arith_method(operator.div, 'divide') |
1218 | 1228 | multiply = mul = _panel_arith_method(operator.mul, 'multiply') |
| 1229 | + |
| 1230 | + try: |
| 1231 | + divide = div = _panel_arith_method(operator.div, 'divide') |
| 1232 | + except AttributeError: # Python 3 |
| 1233 | + divide = div = _panel_arith_method(operator.truediv, 'divide') |
1219 | 1234 |
|
1220 | 1235 | def to_wide(self): |
1221 | 1236 | """ |
|
0 commit comments