apache / apache/arrow

[Python] `tzinfo_to_string` should accept None

Open
#20,172 1 comment 0 reactions 0 assignees View on GitHub
Component: Python Type: enhancement
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 18h
Merged PRs (30d)
91

Description

Currently `tzinfo_to_string` errors with `Not an instance of datetime.tzinfo` when timezone is None. 
```python

>>> tz = None
>>> import pyarrow
>>> pyarrow.lib.tzinfo_to_string(None)
Traceback (most recent call last):
File "", line 1, in
File "pyarrow/types.pxi", line 2080, in pyarrow.lib.tzinfo_to_string
return frombytes(GetResultValue(TzinfoToString(tz)))
File "pyarrow/error.pxi", line 143, in pyarrow.lib.pyarrow_internal_check_status
return check_status(status)
File "pyarrow/error.pxi", line 122, in pyarrow.lib.check_status
raise ArrowTypeError(message)
pyarrow.lib.ArrowTypeError: Not an instance of datetime.tzinfo
```
`tzinfo_to_string` should accept None also. With this `arrays()` in python/pyarrow/tests/strategies.py in case of timestamp dtype should also accept None.

See
- [https://github.com/apache/arrow/pull/12522#discussion_r822637011](https://github.com/apache/arrow/pull/12522#discussion_r837216640)
-

**Reporter**: [Alenka Frim](https://issues.apache.org/jira/browse/ARROW-16056) / @AlenkaF

**Note**: *This issue was originally created as [ARROW-16056](https://issues.apache.org/jira/browse/ARROW-16056). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*

Contributor guide

Open the contributing guide

Research direction

Start with the tzinfo_to_string entry point in pyarrow/types.pxi and inspect the timestamp handling in python/pyarrow/tests/strategies.py. Reproduce the None case, then run the relevant Python tests and confirm that tzinfo_to_string(None) succeeds and timestamp arrays() strategies accept None.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.