Skip to content

Commit f7b8299

Browse files
committed
use divide instead of multiply
1 parent 4936e7d commit f7b8299

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

pandas/core/arrays/arrow/array.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2917,11 +2917,9 @@ def _dt_to_pytimedelta(self) -> np.ndarray:
29172917
return np.array(data, dtype=object)
29182918

29192919
def _dt_total_seconds(self) -> Self:
2920-
# Convert duration to seconds using PyArrow compute
29212920
unit = self._pa_array.type.unit
2922-
unit_to_seconds = {"s": 1.0, "ms": 1e-3, "us": 1e-6, "ns": 1e-9}
2923-
factor = unit_to_seconds[unit]
2924-
result = pc.multiply(pc.cast(self._pa_array, pa.int64()), factor)
2921+
unit_per_second = {"s": 1, "ms": 1000, "us": 1_000_000, "ns": 1_000_000_000}
2922+
result = pc.divide(pc.cast(self._pa_array, pa.int64()), unit_per_second[unit])
29252923
return self._from_pyarrow_array(result)
29262924

29272925
def _dt_as_unit(self, unit: str) -> Self:

0 commit comments

Comments
 (0)