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

Potential improvement for DataFrame Access docs #1001

Closed
mooreryan opened this issue Oct 13, 2024 · 1 comment
Closed

Potential improvement for DataFrame Access docs #1001

mooreryan opened this issue Oct 13, 2024 · 1 comment

Comments

@mooreryan
Copy link
Contributor

I was thinking that it could be useful to mention what happens when trying to access a DataFrame column that does not exist.

The docs mention that DataFrame implements Access:

Explorer.DataFrame also implements the Access behaviour (also known as the brackets syntax).

When using the bracket access syntax, an error is raised rather than returning nil, as the Access docs mention:

Both return nil if the key does not exist

Here is what happens:

df =
  DataFrame.new(
    a: [1, 2, 3],
    b: [10, 20, 30]
  )

df["c"]

** (ArgumentError) could not find column name "c". The available columns are: ["a", "b"].
If you are attempting to interpolate a value, use ^c.

I was thinking an example like this in the DataFrame docs could be helpful. If this would be welcome, I could open a PR request for review.

(For more context, this is related to a question I asked on the Elixir Forum.)

@josevalim
Copy link
Member

Please send a PR adding clarifications to our docs on Access, we can work on it together :)

mooreryan added a commit to mooreryan/explorer that referenced this issue Oct 14, 2024
Add an example showing what happens when trying to access a data frame column that does not exist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants