8000 BUG: np.timedelta64('NaT').__format__ throws TypeError · Issue #17552 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
BUG: np.timedelta64('NaT').__format__ throws TypeError #17552
Closed
@brandon-b-miller

Description

@brandon-b-miller

Substituting a NaT timedelta or datetime into an f-string seems to throw an error. Calling str() on the object beforehand seems to fix the issue.

Reproducing code example:

import numpy as np
x = np.timedelta64('NaT', 'ns')
f"{x}"

Error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

NumPy/Python version information:

In [5]: print(sys.version)
3.7.8 | packaged by conda-forge | (default, Jul 31 2020, 02:25:08) 
[GCC 7.5.0]

In [6]: print(numpy.__version__)
1.19.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0