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.)
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
implementsAccess
:When using the bracket access syntax, an error is raised rather than returning
nil
, as theAccess
docs mention:Here is what happens:
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.)