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.


[View source]
def self.new #

Creates an empty Column.


[View source]

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.


[View source]
def [](index : Int32) #

Returns the element at the given index.


[View source]
def avg : Float64 #

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

Raises NonNumericTypeError if T is not numeric.


[View source]
def map(& : T | Nil -> T | Nil) : Column(T) #

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


[View source]
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.


[View source]
def max(*args, **options) #

[View source]
def max(*args, **options, &) #

[View source]
def min(*args, **options) #

[View source]
def min(*args, **options, &) #

[View source]
def mode : Array(T) #

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


[View source]
def size(*args, **options) #

[View source]
def size(*args, **options, &) #

[View source]
def sum : T #

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

Raises NonNumericTypeError if T is not numeric.


[View source]
def to_a : Array(T | Nil) #

Returns an Array containing the elements of self.


[View source]
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.


[View source]
def unsafe_fetch(index : Int) : T | Nil #

[View source]
def unsafe_put(index : Int, value : T) #

[View source]