apache / apache/arrow

[C++][Python] Add multiply/divide kernels for duration and float/double

Open
#48,003 21 comments 0 reactions 0 assignees View on GitHub
Component: C++ Type: enhancement
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the enhancement requested

`numpy` supports multiplying/dividing `timedelta` values with floats and performs automatic rounding to the current unit, e.g.

```python
>>> import numpy as np
>>> x = np.array([0, 1, 2, 3, 4, 5], dtype="timedelta64[s]")
>>> x * 0.5
array([0, 0, 1, 1, 2, 2], dtype='timedelta64[s]')
>>> x * 1.5
array([0, 1, 3, 4, 6, 7], dtype='timedelta64[s]')
```

This is very useful for ML applications where one needs to transform timestamps first to durations and then to floats (and back after performing a forecast). It would be very nice if `pyarrow` supported this as well, so one can directly work with arrow dtypes.

### Component(s)

C++

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.