elixir-explorer / explorer

Series (one-dimensional) and dataframes (two-dimensional) for fast and elegant data exploration in Elixir
https://hexdocs.pm/explorer
MIT License
1.12k stars 123 forks source link

Support single `on` option in `Dataframe.join` #865

Closed pcapel closed 9 months ago

pcapel commented 9 months ago

I'm curious what you're thoughts are on:

  1. Allowing a single value as valid (as opposed to a list) in join (e.g. DF.join(df, on: :some_column) becomes valid)
  2. Giving an argument error when a list isn't given.

I was quickly moving through the docs and didn't notice the given examples all used a list of column names. The exception that is raised here is not very intuitive:

** (CaseClauseError) no case clause matching: {:fips, :inner}
    (explorer 0.8.0) lib/explorer/data_frame.ex:4931: Explorer.DataFrame.join/3
    #cell:rr454i5svjo3vvcp:1: (file)

Where in this case :fips is the column I would like to use. It seems like updating the case could work. Alternatively the case could default to an error that explains the issue more clearly.

In my opinion, allowing a single column value seems like the reasonable behavior. Happy to write up a PR for either case.

josevalim commented 9 months ago

Good idea. We should wrap the on option with List.wrap :)