-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: Unify number recognition tests for all parsers #38954
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
Conversation
pandas/io/parsers.py
Outdated
@@ -2349,12 +2349,12 @@ def __init__(self, f: Union[FilePathOrBuffer, List], **kwds): | |||
|
|||
decimal = re.escape(self.decimal) | |||
if self.thousands is None: | |||
regex = fr"^\-?[0-9]*({decimal}[0-9]*)?([0-9](E|e)\-?[0-9]*)?$" | |||
regex = fr"^[\-|\+]?[0-9]*({decimal}[0-9]*)?([0-9]?(E|e)\-?[0-9]+)?$" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the |
necessary inside []
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, thanks.
("1_,", 1.0), | ||
("1_234,56", 1234.56), | ||
("1_234,56e0", 1234.56), | ||
# negative cases; must not parse as float |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add something in the docstring about this, i.e. how to interpret the tuple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, done
very nice @phofl |
Minor regex improvements.
Is a fixture the right thing to do here?