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

The behaviour for DataFrame backends.

Link to this section Summary

Callbacks

Functions

Default inspect implementation for backends.

Creates a new DataFrame for a given backend.

Link to this section Types

@type basic_types() :: float() | integer() | String.t() | Date.t() | DateTime.t()
@type column_name() :: String.t()
@type columns_for_io() :: [column_name()] | [pos_integer()] | nil
@type compression() :: {algorithm :: atom() | nil, level :: integer() | nil}
@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 ok_result() :: :ok | {:error, term()}
@type result(t) :: {:ok, t} | {:error, term()}
@type series() :: Explorer.Series.t()
@type t() :: struct()

Link to this section Callbacks

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()
Link to this callback

concat_columns(list, out_df)

View Source
@callback concat_columns([df()], out_df :: df()) :: df()
Link to this callback

concat_rows(list, out_df)

View Source
@callback concat_rows([df()], out_df :: 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()
Link to this callback

dummies(df, out_df, columns)

View Source
@callback dummies(df(), out_df :: 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()) ::
  result(binary())
Link to this callback

dump_ipc(df, compression)

View Source
@callback dump_ipc(df(), compression()) :: result(binary())
Link to this callback

dump_ipc_stream(df, compression)

View Source
@callback dump_ipc_stream(df(), compression()) :: result(binary())
@callback dump_ndjson(df()) :: result(binary())
Link to this callback

dump_parquet(df, compression)

View Source
@callback dump_parquet(df(), compression()) :: result(binary())
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 :: columns_for_io(),
  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 :: columns_for_io()
) :: result(df())
Link to this callback

from_ipc_stream(filename, columns)

View Source
@callback from_ipc_stream(
  filename :: String.t(),
  columns :: columns_for_io()
) :: 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()
Link to this callback

load_csv( contents, dtypes, delimiter, null_character, skip_rows, header?, encoding, max_rows, columns, infer_schema_length, parse_dates )

View Source
@callback load_csv(
  contents :: 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 :: columns_for_io(),
  infer_schema_length :: integer() | nil,
  parse_dates :: boolean()
) :: result(df())
Link to this callback

load_ipc(contents, columns)

View Source
@callback load_ipc(
  contents :: binary(),
  columns :: columns_for_io()
) :: result(df())
Link to this callback

load_ipc_stream(contents, columns)

View Source
@callback load_ipc_stream(
  contents :: binary(),
  columns :: columns_for_io()
) :: result(df())
Link to this callback

load_ndjson(contents, infer_schema_length, batch_size)

View Source
@callback load_ndjson(
  contents :: String.t(),
  infer_schema_length :: integer(),
  batch_size :: integer()
) :: result(df())
@callback load_parquet(contents :: binary()) :: result(df())
@callback mask(df(), mask :: series()) :: 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, out_df, id_columns, names_from, values_from, names_prefix)

View Source
@callback pivot_wider(
  df(),
  out_df :: 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

put(df, out_df, column_name, series)

View Source
@callback put(df(), out_df :: df(), column_name(), series()) :: df()
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_or_frac, replacement, seed)

View Source
@callback sample(df(), n_or_frac :: number(), replacement :: boolean(), seed :: integer()) ::
  df()
@callback select(df(), out_df :: df()) :: df()
@callback slice(
  df(),
  indices :: [integer()] | %Range{first: term(), last: term(), step: term()}
) :: df()
Link to this callback

slice(df, offset, length)

View Source
@callback slice(df(), offset :: integer(), length :: integer()) :: 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()
) :: ok_result()
Link to this callback

to_ipc(df, filename, compression)

View Source
@callback to_ipc(df(), filename :: String.t(), compression()) :: ok_result()
Link to this callback

to_ipc_stream(df, filename, compression)

View Source
@callback to_ipc_stream(
  df(),
  filename :: String.t(),
  compression()
) :: ok_result()
@callback to_lazy(df()) :: df()
@callback to_ndjson(df(), filename :: String.t()) :: ok_result()
Link to this callback

to_parquet(df, filename, compression)

View Source
@callback to_parquet(
  df(),
  filename :: String.t(),
  compression()
) :: ok_result()
@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.