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

use strings (not atoms) for column names in dtype specification #62

Merged
merged 2 commits into from
Sep 21, 2021

Conversation

cigrainger
Copy link
Member

See #58

@cigrainger cigrainger self-assigned this Sep 21, 2021
@cigrainger cigrainger merged commit dc21df8 into main Sep 21, 2021
@cigrainger cigrainger deleted the cigrainger/use-strings-for-dtypes branch September 21, 2021 01:42
@@ -54,7 +54,7 @@ defmodule Explorer.DataFrame do
## Options

* `delimiter` - A single character used to separate fields within a record. (default: `","`)
* `dtypes` - A keyword list of `[column_name: dtype]`. If `nil`, dtypes are imputed from the first 1000 rows. (default: `nil`)
* `dtypes` - A list of `{"column_name", dtype}` tuples. Uses column names as read, not as defined in options. If `nil`, dtypes are imputed from the first 1000 rows. (default: `nil`)
Copy link
Member

Choose a reason for hiding this comment

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

Just to throw out there, cause I am not sure it is a good idea, you could also make this be: dtypes: [string: "foo", string: "bar", integer: "baz"].

Choose a reason for hiding this comment

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

I personally like the 2-tuples better

@@ -33,7 +33,7 @@ defmodule Explorer.PolarsBackend.DataFrame do
dtypes =
if dtypes do
Enum.map(dtypes, fn {colname, dtype} ->
{Atom.to_string(colname), Shared.internal_from_dtype(dtype)}
{colname, Shared.internal_from_dtype(dtype)}
Copy link
Member

Choose a reason for hiding this comment

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

It is probably worth adding some validation here (check the types and raise invalid dtype otherwise).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants