Sha256: d7388060a68b707bca91e01c40060feeaf280df2682031c4c16501f0b1a3df8d

Contents?: true

Size: 1.59 KB

Versions: 39

Compression:

Stored size: 1.59 KB

Contents

module Polars
  module Functions
    # Convert categorical variables into dummy/indicator variables.
    #
    # @param df [DataFrame]
    #   DataFrame to convert.
    # @param columns [Array, nil]
    #   A subset of columns to convert to dummy variables. `nil` means
    #   "all columns".
    #
    # @return [DataFrame]
    def get_dummies(df, columns: nil)
      df.to_dummies(columns: columns)
    end

    # Aggregate to list.
    #
    # @return [Expr]
    def to_list(name)
      col(name).list
    end

    # Compute the spearman rank correlation between two columns.
    #
    # Missing data will be excluded from the computation.
    #
    # @param a [Object]
    #   Column name or Expression.
    # @param b [Object]
    #   Column name or Expression.
    # @param ddof [Integer]
    #   Delta degrees of freedom
    # @param propagate_nans [Boolean]
    #   If `True` any `NaN` encountered will lead to `NaN` in the output.
    #   Defaults to `False` where `NaN` are regarded as larger than any finite number
    #   and thus lead to the highest rank.
    #
    # @return [Expr]
    def spearman_rank_corr(a, b, ddof: 1, propagate_nans: false)
      corr(a, b, method: "spearman", ddof: ddof, propagate_nans: propagate_nans)
    end

    # Compute the pearson's correlation between two columns.
    #
    # @param a [Object]
    #   Column name or Expression.
    # @param b [Object]
    #   Column name or Expression.
    # @param ddof [Integer]
    #   Delta degrees of freedom
    #
    # @return [Expr]
    def pearson_corr(a, b, ddof: 1)
      corr(a, b, method: "pearson", ddof: ddof)
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
polars-df-0.14.0-x86_64-linux lib/polars/functions.rb
polars-df-0.14.0-x86_64-linux-musl lib/polars/functions.rb
polars-df-0.14.0-x86_64-darwin lib/polars/functions.rb
polars-df-0.14.0-x64-mingw-ucrt lib/polars/functions.rb
polars-df-0.14.0-arm64-darwin lib/polars/functions.rb
polars-df-0.14.0-aarch64-linux lib/polars/functions.rb
polars-df-0.14.0-aarch64-linux-musl lib/polars/functions.rb
polars-df-0.14.0 lib/polars/functions.rb
polars-df-0.13.0-x86_64-linux lib/polars/functions.rb
polars-df-0.13.0-x86_64-linux-musl lib/polars/functions.rb
polars-df-0.13.0-x86_64-darwin lib/polars/functions.rb
polars-df-0.13.0-x64-mingw-ucrt lib/polars/functions.rb
polars-df-0.13.0-arm64-darwin lib/polars/functions.rb
polars-df-0.13.0-aarch64-linux lib/polars/functions.rb
polars-df-0.13.0-aarch64-linux-musl lib/polars/functions.rb
polars-df-0.13.0 lib/polars/functions.rb
polars-df-0.12.0-x86_64-linux lib/polars/functions.rb
polars-df-0.12.0-x86_64-linux-musl lib/polars/functions.rb
polars-df-0.12.0-x86_64-darwin lib/polars/functions.rb
polars-df-0.12.0-arm64-darwin lib/polars/functions.rb