Add conversion of state label columns to str if necessary#22
Merged
ianmkenney merged 3 commits intoBecksteinlab:masterfrom Dec 18, 2023
Merged
Add conversion of state label columns to str if necessary#22ianmkenney merged 3 commits intoBecksteinlab:masterfrom
ianmkenney merged 3 commits intoBecksteinlab:masterfrom
Conversation
pd.read_csv by default sets columns to int or float if they are purely numeric, which causes the string matching done later to fail and return an empty dataframe (which then throws an error when attempting to access its elements)
ianmkenney
requested changes
Dec 15, 2023
Member
ianmkenney
left a comment
There was a problem hiding this comment.
pandas uses object arrays for strings because of their variable length and is really an issue for performance. I'm not sure how long the object solution will work. It might break if they change string representations. For instance see this experimental feature in pandas.
I would instead suggest we tell read_csv which datatypes are needed for each column. You can specify str for the state columns and it will default to the object datatype. I assume that if they change how they represent strings, this will still work.
Contributor
Author
|
Good idea, changed to use dtype kwarg in pd.read_csv instead to specify the state columns should be str. |
ianmkenney
reviewed
Dec 18, 2023
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
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.
pd.read_csv by default sets columns to int or float if they are purely numeric, which causes the string matching done later to fail and return an empty dataframe (which then throws an error when attempting to access its elements)