Skip to content
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

Allow developers to supply their own function to infer column data types from data while loading CSVs #7141

Open
sevenzees opened this issue Apr 26, 2024 · 0 comments · May be fixed by #7142
Labels
enhancement New feature or request untriaged New issue has not been triaged

Comments

@sevenzees
Copy link

sevenzees commented Apr 26, 2024

Is your feature request related to a problem? Please describe.
Currently when you use LoadCsv or LoadCsvFromString without supplying data types for each column, the code will try to guess the data types based on the data in the CSV file. This is good, but the problem is that the default type inference code only considers bool, float, DateTime, and string for column types. Sometimes the user may need another data type, such as int, long, or double (see issue 6347 for an example where someone had a problem with the float data type that was chosen by default) but not know the structure of the data ahead of time.

Describe the solution you'd like
I would like to be able to pass in my own custom type inference logic to override the default GuessKind implementation that is given in the library right now. If no custom guess type function is provided to the LoadCsv or LoadCsvFromString methods, then the code should work the same as it does today.

Describe alternatives you've considered
The alternative is to call LoadCsv/LoadCsvFromString with dataTypes set to an array filled with typeof(string) for each column in your data, and then run your logic on the DataFrame with all string type columns to convert the columns to the data types that make sense for each column based on the data that is in each column.

Additional context
I already have implemented a fix for this issue that I would like to merge in with a pull request.

@sevenzees sevenzees added the enhancement New feature or request label Apr 26, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged label Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request untriaged New issue has not been triaged
Projects
None yet
1 participant