Struct rusty_data::datatable::DataColumn [] [src]

pub struct DataColumn {
    pub name: Option<String>,
    // some fields omitted
}

A data column consisting of Strings.

Fields

The name associated with the DataColumn.

Methods

impl DataColumn
[src]

Constructs an empty data column.

Gets the length of the data column.

Gets an immutable reference to the underlying data.

Gets an immutable reference to the categories Option.

Update the categories set using the current data.

Examples

use rusty_data::datatable::DataColumn;

let mut dc = DataColumn::empty();

dc.push("Class1".to_string());
dc.push("Class2".to_string());
dc.push("Class2".to_string());

dc.update_categories();
let categories = dc.categories().unwrap();

// Note that `contains` requires a reference so we pass an &str.
assert!(categories.contains_key("Class2"));
assert_eq!(categories.len(), 2);

Produce a numerical vector representation of the category data.

Examples

use rusty_data::datatable::DataColumn;

let mut dc = DataColumn::empty();

dc.push("Class1".to_string());
dc.push("Class2".to_string());
dc.push("Class2".to_string());

dc.update_categories();

let data = dc.numeric_category_data::<f64>().unwrap();

println!("The data is: {:?}", data);

Pushes a new &str to the column.

Try to get the element at the index as the requested type.

Failures

  • DataCastError : The element at the given index could not be parsed to this type.

Shrink the column to fit the data.

Consumes self and returns a Vec of the requested type.

Failures

  • DataCastError : Returned when the data cannot be parsed to the requested type.

Cast the data to the requested type.

Returns a Vec of the requested type wrapped in an option.

Consumes self and returns an iterator which parses the data to the specified type returning results.

The iterator will return a result on next() detailing the outcome of the parse.

Trait Implementations

impl Index<usize> for DataColumn
[src]

The returned type after indexing

The method for the indexing (container[index]) operation