class Dataframe::Column(T)
- Dataframe::Column(T)
- Reference
- Object
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.crConstructors
-
.new(new_data : Array(Type))
Creates a
Column
from the values in new_data. -
.new
Creates an empty
Column
.
Instance Method Summary
-
#==(other : Column) : Bool
Equality.
-
#[](index : Int32)
Returns the element at the given index.
-
#avg : Float64
Returns the average of all non-nil elements of
self
. -
#map(& : T | Nil -> T | Nil) : Column(T)
Returns a
Column
with the results of running the block against each element of the collection. -
#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. - #max(*args, **options)
- #max(*args, **options, &)
- #min(*args, **options)
- #min(*args, **options, &)
-
#mode : Array(T)
Returns the most non-nil element of highest frequency in
self
. - #size(*args, **options)
- #size(*args, **options, &)
-
#sum : T
Returns the sum of all non-nil elements of
self
. -
#to_a : Array(T | Nil)
Returns an
Array
containing the elements ofself
. -
#to_s(io : IO) : Nil
Prints a nicely readable and concise string representation of this Column to io.
- #unsafe_fetch(index : Int) : T | Nil
- #unsafe_put(index : Int, value : T)
Constructor Detail
Instance Method Detail
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.
Returns the average of all non-nil elements of self
.
Raises NonNumericTypeError
if T is not numeric.
Returns a Column
with the results of running the block against each element
of the collection.
Invokes the given block for each element of self
, replacing the element with
the value returned by the block.
Returns the sum of all non-nil elements of self
.
Raises NonNumericTypeError
if T is not numeric.
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.