BUG: datetime64(np.int64(123), 'ns') fails but datetime64(123, 'ns') is ok
Open
Nobody has claimed this yet.
00 - Bug
- Dominant language
- Python
- Stars
- 32.8k
- Forks
- 12.8k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 197
Description
Describe the issue:
converting integers to np.datetime64 fails for numpy np.int64 integers.
np.datetime64(np.int64(123), 'ns') # ValueError: Could not convert object to NumPy datetime
np.datetime64(123, 'ns') # ok
Reproduce the code example:
np.datetime64(np.int64(123), 'ns') # ValueError: Could not convert object to NumPy datetime
np.datetime64(123, 'ns') # ok
Error message:
np.datetime64(np.int64(123), 'ns')
*** ValueError: Could not convert object to NumPy datetime
NumPy/Python version information:
1.23.2 3.8.10 (default, Jun 22 2022, 20:18:18)
[GCC 9.4.0]
Context for the issue:
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two np.datetime64 examples from the issue, using the reported NumPy and Python versions if available. Trace the conversion path for np.int64 values and compare it with native integers; done means np.datetime64(np.int64(123), 'ns') succeeds consistently without changing the native-integer behavior.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100