Update _isnumber to ensure the output string convertible to float by zhihanyue · Pull Request #252 · astanin/python-tabulate · GitHub
Skip to content

Update _isnumber to ensure the output string convertible to float#252

Open
zhihanyue wants to merge 2 commits into
astanin:masterfrom
zhihanyue:patch-1
Open

Update _isnumber to ensure the output string convertible to float#252
zhihanyue wants to merge 2 commits into
astanin:masterfrom
zhihanyue:patch-1

Conversation

@zhihanyue

@zhihanyue zhihanyue commented Feb 17, 2023

Copy link
Copy Markdown

The numpy.datetime64[ns] was recognized as float, because numpy.datetime64[ns] is convertible to float. This PR fixes this problem.

Fix #251

@andy-maier

andy-maier commented May 11, 2023

Copy link
Copy Markdown
Contributor

@pjkundert

pjkundert commented Oct 8, 2024

Copy link
Copy Markdown
Contributor

I argue in #351 that, if you have a type that converts both to int/float and to str, and you explicitly prefer the str representation -- that you should either:

  1. convert the types to the desired str representation before youtabulate, or
  2. ensure that at least one other value in the column is a str, causing tabulate to prefer their str representation

Otherwise, the (much more common) situation -- where you tabulate types that are convertible to int/float -- would be greatly interfered with by a change such as this.

Ah; as you found disable_numparse, I recommend we close this issue!

@astanin

astanin commented Jul 23, 2025

Copy link
Copy Markdown
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

numpy.datetime64[ns] is wrongly formatted as float

4 participants