apache / apache/arrow

[Python] data loss converting to Table from pandas Timedelta built using `replace`

Open
#49,222 2 comments 0 reactions 0 assignees View on GitHub
Component: Python Type: bug
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the bug, including details regarding any error messages, version, and platform.

When I try to create a `Table` containing a pandas `Timedelta` that was built using `Timestamp.replace`, the data is lost and reset to 0.

For example:
```python
import pandas as pd
import pyarrow as pa

now = pd.Timestamp("2022-03-03 10:00:00", tz='America/New_York')
start_of_day = now.replace(hour=0, minute=0, second=0, microsecond=0, nanosecond=0)
data = {'delta': [now - start_of_day]}
data2 = pa.Table.from_pydict(data)
print(f"data: {data['delta'][0]}")
print(f"data2: {data2['delta'][0]}")
```

Output:
```
data: 0 days 10:00:00
data2: 0:00:00
```

The `data2` line should show 10 hours, not 0 hours.

This only happens if the delta was built using a `Timestamp` that was created using `replace` on another `Timestamp`.

Python 3.13.3
pyarrow 23.0.0
Linux x86_64

### Component(s)

Python

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.