Skip to content

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

Merged
merged 4 commits into from
Jan 4, 2021

Conversation

phofl
Copy link
Member

@phofl phofl commented Jan 4, 2021

Minor regex improvements.
Is a fixture the right thing to do here?

@phofl phofl added Clean IO CSV read_csv, to_csv labels Jan 4, 2021
@@ -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]+)?$"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the | necessary inside []?

Copy link
Member Author

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

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, done

@jreback jreback added this to the 1.3 milestone Jan 4, 2021
@jreback jreback merged commit 1f22da1 into pandas-dev:master Jan 4, 2021
@jreback
Copy link
Contributor

jreback commented Jan 4, 2021

very nice @phofl

@phofl phofl deleted the 38926 branch January 4, 2021 23:23
luckyvs1 pushed a commit to luckyvs1/pandas that referenced this pull request Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean IO CSV read_csv, to_csv
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLN: Unify number recognition tests in read_csv for all parsers
3 participants