Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Explorer: 02 - Getting started

02_getting_started_with_explorer.livemd

Explorer: 02 - Getting started

Mix.install([{:explorer, "~> 0.9.2"}])

Your first dataframe

df = Explorer.DataFrame.new(
  city: ["New York", "Los Angeles", "Chicago"],
  population: [8_419_000, 3_979_000, 2_716_000]
)
#Explorer.DataFrame<
  Polars[3 x 2]
  city string ["New York", "Los Angeles", "Chicago"]
  population s64 [8419000, 3979000, 2716000]
>

Using an alias

In Elixir, we ususually use alias to create an alias for a module. For example:

alias Explorer.DataFrame, as: DF

But with Explorer, its recommended to use require instead, like the following:

require Explorer.DataFrame, as: DF

The reason for this is that require will load Explorer’s macro features which allow for a friendly way to query dataframes. The macros compile regular Elixir code to a form for efficient dataframes operations.

More information:

require Explorer.DataFrame, as: DF
Explorer.DataFrame
df = DF.new(
  city: ["New York", "Los Angeles", "Chicago"],
  population: [8_419_000, 3_979_000, 2_716_000]
)
#Explorer.DataFrame<
  Polars[3 x 2]
  city string ["New York", "Los Angeles", "Chicago"]
  population s64 [8419000, 3979000, 2716000]
>