View Source Explorer.Backend.DataFrame behaviour (Explorer v0.3.1)

The behaviour for DataFrame backends.

Link to this section Summary

Functions

Default inspect implementation for backends.

Creates a new DataFrame for a given backend.

Link to this section Types

@type column_name() :: String.t()
@type df() :: Explorer.DataFrame.t()
@type dtype() :: Explorer.Series.dtype()
@type dtypes() :: %{required(column_name()) => dtype()}
@type lazy_frame() :: Explorer.Backend.LazyFrame.t()
@type lazy_series() :: Explorer.Backend.LazySeries.t()
@type mutate_value() ::
  series()
  | basic_types()
  | [basic_types()]
  | (df() -> series() | basic_types() | [basic_types()])
@type result(t) :: {:ok, t} | {:error, term()}
@type series() :: Explorer.Series.t()
@type t() :: struct()

Link to this section Callbacks

@callback arrange(df(), columns :: [{:asc | :desc, column_name()}]) :: df()
Link to this callback

arrange_with(df, out_df, directions)

View Source
@callback arrange_with(
  df(),
  out_df :: df(),
  directions :: [{:asc | :desc, lazy_series()}]
) :: df()
@callback collect(df()) :: df()
@callback concat_columns([df()]) :: df()
@callback concat_rows([df()]) :: df()
Link to this callback

distinct(df, out_df, columns, keep_all)

View Source
@callback distinct(
  df(),
  out_df :: df(),
  columns :: [column_name()],
  keep_all :: boolean()
) :: df()
@callback drop_nil(df(), columns :: [column_name()]) :: df()
@callback dummies(df(), columns :: [column_name()]) :: df()
Link to this callback

dump_csv(df, header?, delimiter)

View Source
@callback dump_csv(df(), header? :: boolean(), delimiter :: String.t()) :: String.t()
Link to this callback

filter_with(df, out_df, lazy_series)

View Source
@callback filter_with(df(), out_df :: df(), lazy_series()) :: df()
Link to this callback

from_csv( filename, dtypes, delimiter, null_character, skip_rows, header?, encoding, max_rows, columns, infer_schema_length, parse_dates )

View Source
@callback from_csv(
  filename :: String.t(),
  dtypes :: [{column_name(), dtype()}],
  delimiter :: String.t(),
  null_character :: String.t(),
  skip_rows :: integer(),
  header? :: boolean(),
  encoding :: String.t(),
  max_rows :: integer() | nil,
  columns :: [column_name()] | [atom()] | [integer()] | nil,
  infer_schema_length :: integer() | nil,
  parse_dates :: boolean()
) :: result(df())
Link to this callback

from_ipc(filename, columns)

View Source
@callback from_ipc(
  filename :: String.t(),
  columns :: [String.t()] | [atom()] | [integer()] | nil
) :: result(df())
Link to this callback

from_ndjson(filename, infer_schema_length, batch_size)

View Source
@callback from_ndjson(
  filename :: String.t(),
  infer_schema_length :: integer(),
  batch_size :: integer()
) :: result(df())
@callback from_parquet(filename :: String.t()) :: result(df())
@callback from_series(map() | Keyword.t()) :: df()
@callback from_tabular(Table.Reader.t()) :: df()
@callback head(df(), rows :: integer()) :: df()
@callback inspect(df(), opts :: Inspect.Opts.t()) :: Inspect.Algebra.t()
Link to this callback

join(left, right, out_df, on, how)

View Source
@callback join(
  left :: df(),
  right :: df(),
  out_df :: df(),
  on :: [{column_name(), column_name()}],
  how :: :left | :inner | :outer | :right | :cross
) :: df()
@callback lazy() :: module()
@callback mask(df(), mask :: series()) :: df()
Link to this callback

mutate(df, out_df, mutations)

View Source
@callback mutate(df(), out_df :: df(), mutations :: [{column_name(), mutate_value()}]) ::
  df()
Link to this callback

mutate_with(df, out_df, mutations)

View Source
@callback mutate_with(df(), out_df :: df(), mutations :: [{column_name(), lazy_series()}]) ::
  df()
@callback n_rows(df()) :: integer()
Link to this callback

pivot_longer(df, out_df, columns_to_pivot, columns_to_keep, names_to, values_to)

View Source
@callback pivot_longer(
  df(),
  out_df :: df(),
  columns_to_pivot :: [column_name()],
  columns_to_keep :: [column_name()],
  names_to :: column_name(),
  values_to :: column_name()
) :: df()
Link to this callback

pivot_wider(df, id_columns, names_from, values_from, names_prefix)

View Source
@callback pivot_wider(
  df(),
  id_columns :: [column_name()],
  names_from :: column_name(),
  values_from :: column_name(),
  names_prefix :: String.t()
) :: df()
@callback pull(df(), column :: column_name()) :: series()
Link to this callback

rename(df, out_df, list)

View Source
@callback rename(df(), out_df :: df(), [{old :: column_name(), new :: column_name()}]) ::
  df()
Link to this callback

sample(df, n, replacement, seed)

View Source
@callback sample(df(), n :: integer(), replacement :: boolean(), seed :: integer()) ::
  df()
@callback select(df(), out_df :: df()) :: df()
@callback slice(df(), indices :: [integer()]) :: df()
Link to this callback

slice(df, offset, length)

View Source
@callback slice(df(), offset :: integer(), length :: integer()) :: df()
Link to this callback

summarise(df, out_df, aggregations)

View Source
@callback summarise(
  df(),
  out_df :: df(),
  aggregations :: %{required(column_name()) => [atom()]}
) :: df()
Link to this callback

summarise_with(df, out_df, aggregations)

View Source
@callback summarise_with(
  df(),
  out_df :: df(),
  aggregations :: [{column_name(), lazy_series()}]
) :: df()
@callback tail(df(), rows :: integer()) :: df()
Link to this callback

to_csv(df, filename, header?, delimiter)

View Source
@callback to_csv(
  df(),
  filename :: String.t(),
  header? :: boolean(),
  delimiter :: String.t()
) ::
  result(String.t())
Link to this callback

to_ipc(df, filename, compression)

View Source
@callback to_ipc(
  df(),
  filename :: String.t(),
  compression :: {nil | atom(), nil | integer()}
) ::
  result(String.t())
@callback to_lazy(df()) :: df()
@callback to_ndjson(df(), filename :: String.t()) :: result(String.t())
Link to this callback

to_parquet(df, filename, compression)

View Source
@callback to_parquet(
  df(),
  filename :: String.t(),
  compression :: {nil | atom(), nil | integer()}
) :: result(String.t())
@callback to_rows(df(), atom_keys? :: boolean()) :: [map()]

Link to this section Functions

Link to this function

inspect(df, backend, n_rows, inspect_opts, opts \\ [])

View Source

Default inspect implementation for backends.

Link to this function

new(data, names, dtypes)

View Source

Creates a new DataFrame for a given backend.