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:
- Elixir’s official documentation has more information about alias vs require
- Explorer.Query
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]
>