FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

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

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 commented Feb 17, 2023
edited
Loading

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 commented May 11, 2023
edited
Loading

Copy link
Copy Markdown
Contributor

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 commented Oct 8, 2024
edited
Loading

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 commented Jul 23, 2025

Copy link
Copy Markdown
Owner

This PR needs test cases to cover and document all new edge cases, and how they are now handled.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL