pub enum ColumnData {
Numeric(Array1<f64>),
Integer(Array1<i64>),
String(Array1<String>),
Bytes(Array2<u8>),
}Expand description
The values of one column, in the type the source uses.
Every variant except ColumnData::Bytes holds one value per sample.
Bytes holds one row per sample, for a source whose columns have no
individual names.
§Examples
use dataset_ml::table::ColumnData;
use ndarray::array;
let counts = ColumnData::Integer(array![3, 5, 8]);
assert_eq!(counts.len(), 3);
assert_eq!(counts.kind(), "integer");
assert_eq!(counts.width(), 1);Variants§
Numeric(Array1<f64>)
A value with a fraction. A missing value is f64::NAN.
Integer(Array1<i64>)
A whole number.
String(Array1<String>)
Text, spelled as the source spells it. A missing value is the empty string, unless the dataset documents its own token.
Bytes(Array2<u8>)
A fixed-width row of unsigned bytes per sample, such as the pixels of an image. The columns inside the row have no individual names.
Implementations§
Source§impl ColumnData
impl ColumnData
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
The number of samples the column holds.
§Returns
usize- the sample count. ForColumnData::Bytes, this is the number of rows, not the number of bytes.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the column holds no sample.
§Returns
bool-trueif the column holds no sample, andfalseif it holds at least one.
Sourcepub fn kind(&self) -> &'static str
pub fn kind(&self) -> &'static str
The name of the variant this column holds.
§Returns
&'static str- one of"numeric","integer","string", or"bytes".
§Notes
Table::numeric_matrix puts this name in the error it returns for a
column it cannot read as a number.
Sourcepub fn width(&self) -> usize
pub fn width(&self) -> usize
The number of values this column contributes to one row of a matrix.
§Returns
usize- the row width. Every variant contributes1, exceptColumnData::Bytes, which contributes the number of bytes in one of its rows.
Trait Implementations§
Source§impl Clone for ColumnData
impl Clone for ColumnData
Source§fn clone(&self) -> ColumnData
fn clone(&self) -> ColumnData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more