riantr/moonbit_dowhy/api does not have a README file

    Column

    pub enum Column {
    Numeric(Array[Double])
    Discrete(Array[String])
    }

    The payload of a single column.

    Column::discrete

    fn Column::discrete(values : Array[String]) -> Column

    A column of strings.

    The constructor lives in the package that defines the enum, because a variant whose payload is a mutable array cannot be built directly from another package.

    Column::numeric

    fn Column::numeric(values : Array[Double]) -> Column

    A numeric column.

    The constructor lives in the package that defines the enum, because a variant whose payload is a mutable array cannot be built directly from another package.

    DataFrame

    pub struct DataFrame {
    columns : Map[String, Column]
    order : Array[String]
    nrows : Int
    }

    A tabular data frame.

    DataFrame::column

    fn DataFrame::column(self : DataFrame, name : String) -> Column?

    The raw payload of a column.

    DataFrame::column_names

    fn DataFrame::column_names(self : DataFrame) -> Array[String]

    Column names in order.

    DataFrame::copy

    fn DataFrame::copy(self : DataFrame) -> DataFrame

    A copy of the frame.

    The columns are copied as well, so the copy and the original do not share any state.

    DataFrame::design_matrix

    fn DataFrame::design_matrix(self : DataFrame, names : Array[String]) ->
    Matrix

    Build a design matrix from the given numeric columns, in order.

    DataFrame::discrete

    fn DataFrame::discrete(self : DataFrame, name : String) -> Array[String]

    The string values of a column.

    Raises when the column is missing or not discrete.

    DataFrame::filter

    fn DataFrame::filter(self : DataFrame, mask : Array[Bool]) -> DataFrame

    A frame restricted to the rows selected by the mask.

    DataFrame::from_numeric

    fn DataFrame::from_numeric(order : Array[String], columns : Map[String, Array[Double]]) -> DataFrame

    Build a data frame whose columns are all numeric.

    The column order is the order of order.

    DataFrame::group_by

    fn DataFrame::group_by(self : DataFrame, name : String) -> (Array[Double], Array[Array[Int]])

    Split the rows into groups keyed by the value of a numeric column.

    Returns the group keys in ascending order together with the row indices of every group.

    DataFrame::has_column

    fn DataFrame::has_column(self : DataFrame, name : String) -> Bool

    Whether the frame contains the given column.

    DataFrame::is_discrete

    fn DataFrame::is_discrete(self : DataFrame, name : String) -> Bool

    Whether the given column holds discrete values.

    DataFrame::mask_eq

    fn DataFrame::mask_eq(self : DataFrame, name : String, value : Double) -> Array[Bool]

    A mask that selects the rows whose column equals the given value.

    DataFrame::mask_ne

    fn DataFrame::mask_ne(self : DataFrame, name : String, value : Double) -> Array[Bool]

    A mask that selects the rows whose column differs from the given value.

    DataFrame::mask_range

    fn DataFrame::mask_range(self : DataFrame, name : String, lower : Double, upper : Double) -> Array[Bool]

    A mask that selects rows whose numeric column lies in [lower, upper].

    DataFrame::mean

    fn DataFrame::mean(self : DataFrame, name : String) -> Double

    Mean of a numeric column.

    DataFrame::new

    fn DataFrame::new(order : Array[String], columns : Map[String, Column]) -> DataFrame

    Build a data frame from an ordered list of column names and a map of columns.

    DataFrame::nrows

    fn DataFrame::nrows(self : DataFrame) -> Int

    Number of rows.

    DataFrame::numeric

    fn DataFrame::numeric(self : DataFrame, name : String) -> Array[Double]

    The numeric values of a column.

    Raises when the column is missing or not numeric.

    DataFrame::numeric_column_names

    fn DataFrame::numeric_column_names(self : DataFrame) -> Array[String]

    The names of the numeric columns of the frame, in order.

    The estimators use it to pick the columns of a design matrix out of an encoded frame, whose discrete columns became numeric ones.

    DataFrame::of

    fn DataFrame::of(name : String, values : Array[Double]) -> DataFrame

    Build a single column data frame.

    DataFrame::qcut

    fn DataFrame::qcut(self : DataFrame, name : String, q : Int) -> Array[Double]

    Discretise a numeric column into quantile bins, like pandas.qcut.

    The returned column holds the bin index of every row; the bins are the q quantile groups of the values. Rows whose value cannot be assigned (because of too few distinct values) get the bin of their own value.

    DataFrame::select

    fn DataFrame::select(self : DataFrame, names : Array[String]) -> DataFrame

    A frame restricted to the given columns, in the given order.

    DataFrame::sum

    fn DataFrame::sum(self : DataFrame, name : String) -> Double

    Sum of a numeric column.

    DataFrame::take_rows

    fn DataFrame::take_rows(self : DataFrame, rows : Array[Int]) -> DataFrame

    A frame with the given rows, in the given order.

    The rows are given by their index in the frame. An index that is out of range is skipped, so a resample never reads past the end of a column.

    DataFrame::with_column

    fn DataFrame::with_column(self : DataFrame, name : String, column : Column) -> DataFrame

    A frame with an extra (or replaced) column.

    The frame is copied first, so the frame the method is called on is left unchanged; a map is mutated in place and a shared one would change the other frame as well. The number of rows is recomputed, because the new column can be shorter than the frame it is added to.

    DataFrame::with_discrete

    fn DataFrame::with_discrete(self : DataFrame, name : String, values : Array[String]) -> DataFrame

    A frame with an extra discrete column.

    DataFrame::with_numeric

    fn DataFrame::with_numeric(self : DataFrame, name : String, values : Array[Double]) -> DataFrame

    A frame with an extra numeric column.

    Encoders

    pub struct Encoders {
    drop_first : Bool
    encoders : Map[String, OneHotEncoder]
    }

    A registry of the one-hot encoders of a data set.

    This is the port of dowhy.utils.encoding.Encoders: every named set of variables gets its own encoder, so that the same variables are encoded the same way every time.

    Encoders::encode

    fn Encoders::encode(self : Encoders, data : DataFrame, encoder_name : String) -> DataFrame

    Encode the discrete columns of a data frame.

    The encoder of the given name is created when it does not exist yet and is reused afterwards, so that the encoding of a column does not depend on the order the data arrives in.

    Encoders::names

    fn Encoders::names(self : Encoders) -> Array[String]

    The names of the encoders the registry holds.

    Encoders::new

    fn Encoders::new(drop_first : Bool) -> Encoders

    A registry of encoders.

    The first category of every column is dropped unless drop_first is false.

    Encoders::reset

    fn Encoders::reset(self : Encoders) -> Unit

    Forget every encoder, so that the next encoding creates new ones.

    OneHotEncoder

    pub struct OneHotEncoder {
    columns : Array[String]
    categories : Array[Array[String]]
    drop_first : Bool
    }

    The one-hot encoding of the discrete columns of a data frame.

    This is the port of dowhy.utils.encoding, which replaces pandas' get_dummies with sklearn.preprocessing.OneHotEncoder so that new data can be encoded with the encoder that was fitted on the old data, and the encodings stay consistent.

    The categories of a column are its distinct values in lexicographic order, which is what numpy.unique and the sorted categories of pandas produce, and the name of an encoded column is <column>_<category>.

    OneHotEncoder::categories_of

    fn OneHotEncoder::categories_of(self : OneHotEncoder, column : String) -> Array[String]

    The categories of an encoded column, in lexicographic order.

    OneHotEncoder::encoded_columns

    fn OneHotEncoder::encoded_columns(self : OneHotEncoder) -> Array[String]

    The names of the encoded columns.

    OneHotEncoder::fit

    fn OneHotEncoder::fit(data : DataFrame, columns : Array[String], drop_first : Bool) -> OneHotEncoder

    The one-hot encoder of a data frame.

    This is the port of sklearn.preprocessing.OneHotEncoder as the upstream encoding helper uses it: the categories are learned from the data, and the encoder can then encode other data with the same categories.

    OneHotEncoder::get_feature_names_out

    fn OneHotEncoder::get_feature_names_out(self : OneHotEncoder) -> Array[String]

    The names of the columns the encoder produces.

    The name of an encoded column is <column>_<category>, and the name of the first category of a column is missing when the encoder drops it.

    OneHotEncoder::transform

    fn OneHotEncoder::transform(self : OneHotEncoder, data : DataFrame) -> DataFrame

    Encode a data frame with the encoder.

    The columns that are not encoded are kept, in the order they have in the data, and the encoded columns follow them. A value that the encoder has not seen is an error, exactly like it is for sklearn.

    discrete_columns

    fn discrete_columns(data : DataFrame) -> Array[String]

    The names of the discrete columns of a data frame.

    one_hot_encode

    fn one_hot_encode(data : DataFrame, columns : Array[String], drop_first : Bool) -> (DataFrame, OneHotEncoder)

    Encode the discrete columns of a data frame.

    The result is the encoded frame and the encoder that produced it, so that other data can be encoded with it.

    one_hot_encode_with

    fn one_hot_encode_with(data : DataFrame, encoder : OneHotEncoder) -> DataFrame

    Encode a data frame with an encoder that was fitted on other data.

    Powered by MoonBit

    Site sourceReport issueModulesSkillsBuild queueStatistics

    © 2026 mooncakes.io