Make float parsing from CSV round-trip #444
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
pandas
uses by default a C parser for CSV files for performance reasons. The default behaviour of such parser when parsing floating point values from strings is different from Python's behaviour. While Python parsing can be round-tripped (e.g.,float(0.999) == 0.999
) this is not true for the C parser.I believe most users nowadays expect floats to be parsed correctly, so I added a keyword argument to all instances of
pandas.read_csv
asking for the Python-like behaviour. The only downside is that this behaviour is slower (the C code actually calls Python to perform the parsing). This may be more relevant for the parameter table and less important for measurement tables, so it may also be acceptable to enable it only for some tables and not others.