Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zhihanyue
Copy link

@zhihanyue zhihanyue commented Feb 17, 2023

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
Copy link
Contributor

andy-maier commented May 11, 2023

While this PR may solve the issue with numpy.datetime64, it does not go far enough to also fix incorrect conversions of strings to float, e.g. "1E10" becomes 1e+10. See issue #266
I still think this PR can go forward, I just wanted to mention it.

Update: I discovered disable_numparse=True which solves that issue ... never mind ...

@pjkundert
Copy link
Contributor

pjkundert commented Oct 8, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

numpy.datetime64[ns] is wrongly formatted as float
3 participants