class Dataframe::Column(T)

Overview

Column represents a column of values in a Dataframe, cast to one of the Dataframe types (Dataframe::Type).

NOTE: The most common method to get a Column is from Dataframe#columns, which returns a union of all possible types, thus making it necessary to cast the column as the proper type before running any type specific methods.

column = dataframe.columns["Age"].as(Dataframe::Column(Int32))

column.map! do |e|
  e.nil? ? e : e + 1
end

Defined in:

column.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(new_data : Array(Type)) #

Creates a Column from the values in new_data.


def self.new #

Creates an empty Column.


Instance Method Detail

def ==(other : Column) : Bool #

Equality. Returns true if each element in self is equal to each corresponding element in other, and that the type of other is identical to T.


def [](index : Int32) #

Returns the element at the given index.


def avg : Float64 #

Returns the average of all non-nil elements of self.

Raises NonNumericTypeError if T is not numeric.


def map(& : T | Nil -> T | Nil) : Column(T) #

Returns a Column with the results of running the block against each element of the collection.


def map!(& : T | Nil -> T | Nil) : self #

Invokes the given block for each element of self, replacing the element with the value returned by the block.


def max(*args, **options) #

def max(*args, **options, &) #

def min(*args, **options) #

def min(*args, **options, &) #

def mode : Array(T) #

Returns the most non-nil element of highest frequency in self.


def size(*args, **options) #

def size(*args, **options, &) #

def sum : T #

Returns the sum of all non-nil elements of self.

Raises NonNumericTypeError if T is not numeric.


def to_a : Array(T | Nil) #

Returns an Array containing the elements of self.


def to_s(io : IO) : Nil #

Prints a nicely readable and concise string representation of this Column to io.

Each element is presented using its #inspect(io) result to avoid ambiguity.


def unsafe_fetch(index : Int) : T | Nil #

def unsafe_put(index : Int, value : T) #