HiPipe
0.7.0
C++17 data pipeline with Python bindings.
|
Tabular object with convenient data access methods. More...
#include <hipipe/core/dataframe.hpp>
Public Member Functions | |
template<typename T > | |
dataframe (std::vector< std::vector< T >> columns, std::vector< std::string > header={}) | |
template<typename... Ts> | |
dataframe (std::tuple< std::vector< Ts >... > columns, std::vector< std::string > header={}) | |
template<typename Rng , typename ValueT = ranges::range_value_t<Rng>> | |
std::size_t | insert_col (Rng &&rng, std::string col_name={}, std::function< std::string(const ValueT &)> cvt=static_cast< std::string(*)(const ValueT &)>(utility::to_string)) |
template<typename... Ts> | |
std::size_t | insert_row (std::tuple< Ts... > row_tuple, std::tuple< std::function< std::string(const Ts &)>... > cvts=std::make_tuple(static_cast< std::string(*)(const Ts &)>(utility::to_string)...)) |
std::size_t | insert_row (std::vector< std::string > row) |
void | drop_icol (std::size_t col_index) |
void | drop_col (const std::string &col_name) |
void | drop_row (const std::size_t row_idx) |
auto | raw_cols () |
auto | raw_cols () const |
auto | raw_icols (std::vector< std::size_t > col_indexes) |
auto | raw_icols (std::vector< std::size_t > col_indexes) const |
auto | raw_cols (const std::vector< std::string > &col_names) |
auto | raw_cols (const std::vector< std::string > &col_names) const |
template<typename... Ts> | |
auto | icols (std::vector< std::size_t > col_indexes, std::tuple< std::function< Ts(const std::string &)>... > cvts=std::make_tuple(utility::string_to< Ts >...)) const |
template<typename... Ts> | |
auto | cols (const std::vector< std::string > &col_names, std::tuple< std::function< Ts(const std::string &)>... > cvts=std::make_tuple(utility::string_to< Ts >...)) const |
auto | raw_icol (std::size_t col_index) |
auto | raw_icol (std::size_t col_index) const |
auto | raw_col (const std::string &col_name) |
auto | raw_col (const std::string &col_name) const |
template<typename T > | |
auto | icol (std::size_t col_index, std::function< T(const std::string &)> cvt=utility::string_to< T >) const |
template<typename T > | |
auto | col (const std::string &col_name, std::function< T(const std::string &)> cvt=utility::string_to< T >) const |
auto | raw_rows () |
auto | raw_rows () const |
auto | raw_irows (std::vector< std::size_t > col_indexes) |
auto | raw_irows (std::vector< std::size_t > col_indexes) const |
auto | raw_rows (const std::vector< std::string > &col_names) |
auto | raw_rows (const std::vector< std::string > &col_names) const |
template<typename... Ts> | |
auto | irows (std::vector< std::size_t > col_indexes, std::tuple< std::function< Ts(const std::string &)>... > cvts=std::make_tuple(utility::string_to< Ts >...)) const |
template<typename... Ts> | |
auto | rows (const std::vector< std::string > &col_names, std::tuple< std::function< Ts(const std::string &)>... > cvts=std::make_tuple(utility::string_to< Ts >...)) const |
template<typename IndexT , typename ColT > | |
auto | index_icol (std::size_t key_col_index, std::size_t val_col_index, std::function< IndexT(const std::string &)> key_col_cvt=utility::string_to< IndexT >, std::function< ColT(const std::string &)> val_col_cvt=utility::string_to< ColT >) const |
template<typename IndexT , typename ColT > | |
auto | index_col (const std::string &key_col_name, const std::string &val_col_name, std::function< IndexT(const std::string &)> key_col_cvt=utility::string_to< IndexT >, std::function< ColT(const std::string &)> val_col_cvt=utility::string_to< ColT >) const |
template<typename IndexT , typename... Ts> | |
auto | index_icols (std::size_t key_col_index, std::vector< std::size_t > val_col_indexes, std::function< IndexT(const std::string &)> key_col_cvt=utility::string_to< IndexT >, std::tuple< std::function< Ts(const std::string &)>... > val_col_cvts=std::make_tuple(utility::string_to< Ts >...)) const |
template<typename IndexT , typename... Ts> | |
auto | index_cols (const std::string &key_col_name, const std::vector< std::string > &val_col_names, std::function< IndexT(const std::string &)> key_col_cvt=utility::string_to< IndexT >, std::tuple< std::function< Ts(const std::string &)>... > val_col_cvts=std::make_tuple(utility::string_to< Ts >...)) const |
std::size_t | n_cols () const |
Return the number of columns. | |
std::size_t | n_rows () const |
Return the number of rows (excluding header). | |
void | header (std::vector< std::string > new_header) |
std::vector< std::string > | header () const |
Return the names of columns. | |
data_table_t & | data () |
Return a reference to the raw data table. | |
const data_table_t & | data () const |
Return a const reference to the raw data table. | |
Tabular object with convenient data access methods.
By default, all fields are stored as std::string and they are cast to the requested type on demand.
Definition at line 39 of file dataframe.hpp.
|
inline |
Constructs the dataset from a vector of columns of the same type.
Example:
std::invalid_argument | 1) If the header is provided, but some of the column names are empty. 2) If the column sizes mismatch. 3) If the provided header does not match the number of provided columns. |
Definition at line 184 of file dataframe.hpp.
|
inline |
Constructs the dataset from a tuple of columns of possibly different types.
Example:
std::invalid_argument | 1) If the header is provided, but some of the column names are empty. 2) If the column sizes mismatch. 3) If the provided header does not match the number of provided columns. |
Definition at line 215 of file dataframe.hpp.
|
inline |
Return a typed view of a column.
By default, this function does not provide a direct access to the stored data. Instead, each field is converted to the type T and a copy is returned.
Example:
std::out_of_range | If the column is not in the dataframe. |
Definition at line 550 of file dataframe.hpp.
|
inline |
Return a typed view of multiple columns.
Example:
std::out_of_range | If any of the columns is not in the dataframe. |
Definition at line 450 of file dataframe.hpp.
|
inline |
Drop a column with the given name.
std::out_of_range | If the column is not in the dataframe. |
Definition at line 311 of file dataframe.hpp.
|
inline |
Drop a column with the given index.
std::out_of_range | If the column is not in the dataframe. |
Definition at line 295 of file dataframe.hpp.
|
inline |
Drop a row.
std::out_of_range | If the row is not in the dataframe. |
Definition at line 320 of file dataframe.hpp.
|
inline |
Set the column names.
std::invalid_argument | 1) If some of the column names are empty. 2) If the header does not match the number of columns. |
Definition at line 823 of file dataframe.hpp.
|
inline |
Return a typed view of a column.
By default, this function does not provide a direct access to the stored data. Instead, each field is converted to the type T and a copy is returned.
Example:
std::out_of_range | If the column is not in the dataframe. |
Definition at line 531 of file dataframe.hpp.
|
inline |
Return a typed view of multiple columns.
Example:
std::out_of_range | If any of the columns is not in the dataframe. |
Definition at line 428 of file dataframe.hpp.
|
inline |
Return an indexed typed view of a single column.
This function is the same as index_icol(), but columns are selected by name.
std::out_of_range | If any of the columns is not in the dataframe. |
Definition at line 733 of file dataframe.hpp.
|
inline |
Return an indexed typed view of multiple columns.
See index_icol().
This function is similar to index_icols(), but columns are selected by name.
std::out_of_range | If any of the columns is not in the dataframe. |
Definition at line 788 of file dataframe.hpp.
|
inline |
Return an indexed typed view of a single column.
This function returns a range of tuples, where the first tuple element is from the key column and the second element is from the value column. This range can be used to construct a map or a hashmap.
Example:
key_col_index | Index of the column to be used as key. |
val_col_index | Index of the column to be used as value. |
key_col_cvt | Function that is used to convert the keys from std::string to IndexT. |
val_col_cvt | Function that is used to convert the values from std::string to ValueT. |
std::out_of_range | If any of the columns is not in the dataframe. |
Definition at line 710 of file dataframe.hpp.
|
inline |
Return an indexed typed view of multiple columns.
See index_icol().
This function is similar to index_icol(), but value type is a tuple of Ts.
std::out_of_range | If any of the columns is not in the dataframe. |
Definition at line 763 of file dataframe.hpp.
|
inline |
Inserts a new column to the dataframe.
Example:
std::invalid_argument | 1) If the dataframe has a header but no column name was provided. 2) If the column size is not equal to n_rows. |
Definition at line 238 of file dataframe.hpp.
|
inline |
Inserts a new typed row to the dataframe.
Example:
std::invalid_argument | If the row size is not equal to n_cols. |
Definition at line 259 of file dataframe.hpp.
|
inline |
Inserts a new raw row to the dataframe.
Example:
std::invalid_argument | If the row size is not equal to n_cols. |
Definition at line 281 of file dataframe.hpp.
|
inline |
Return a typed view of multiple rows.
This function provides the same data as icols() but transposed.
Example:
std::out_of_range | If any of the columns is not in the dataframe. |
Definition at line 653 of file dataframe.hpp.
|
inline |
Return a raw view of a column.
The data can be directly changed by writing to the view.
Example:
std::out_of_range | If the column is not in the dataframe. |
Definition at line 498 of file dataframe.hpp.
|
inline |
Return a raw view of a column.
This is just a const overload of the non-const raw_col().
std::out_of_range | If the column is not in the dataframe. |
Definition at line 510 of file dataframe.hpp.
|
inline |
Return a raw view of all columns.
The data can be directly changed by writing to the view.
Example:
Definition at line 341 of file dataframe.hpp.
|
inline |
Return a raw view of all columns.
This is just a const overload of the non-const argument-less raw_cols().
Definition at line 351 of file dataframe.hpp.
|
inline |
Return a raw view of multiple columns.
The data can be directly changed by writing to the view.
Example:
std::out_of_range | If any of the columns is not in the dataframe. |
Definition at line 398 of file dataframe.hpp.
|
inline |
Return a raw view of multiple columns.
This is just a const overload of the non-const raw_cols().
std::out_of_range | If any of the columns is not in the dataframe. |
Definition at line 410 of file dataframe.hpp.
|
inline |
Return a raw view of a column.
The data can be directly changed by writing to the view.
Example:
std::out_of_range | If the column is not in the dataframe. |
Definition at line 471 of file dataframe.hpp.
|
inline |
Return a raw view of a column.
std::out_of_range | If the column is not in the dataframe. |
Definition at line 481 of file dataframe.hpp.
|
inline |
Return a raw view of multiple columns.
The data can be directly changed by writing to the view.
Example:
std::out_of_range | If any of the columns is not in the dataframe. |
Definition at line 368 of file dataframe.hpp.
|
inline |
Return a raw view of multiple columns.
This is just a const overload of the non-const raw_icols().
std::out_of_range | If any of the columns is not in the dataframe. |
Definition at line 380 of file dataframe.hpp.
|
inline |
Return a raw view of multiple rows.
Example:
std::out_of_range | If any of the columns is not in the dataframe. |
Definition at line 592 of file dataframe.hpp.
|
inline |
Return a raw view of multiple rows.
This is just a const overload of the non-const raw_irows().
std::out_of_range | If any of the columns is not in the dataframe. |
Definition at line 604 of file dataframe.hpp.
|
inline |
Return a raw view of all rows.
Example:
Definition at line 567 of file dataframe.hpp.
|
inline |
Return a raw view of all rows.
This is just a const overload of the non-const argument-less raw_rows().
Definition at line 577 of file dataframe.hpp.
|
inline |
Return a raw view of multiple rows.
Example:
std::out_of_range | If any of the columns is not in the dataframe. |
Definition at line 620 of file dataframe.hpp.
|
inline |
Return a raw view of multiple rows.
This is just a const overload of the non-const raw_rows().
std::out_of_range | If any of the columns is not in the dataframe. |
Definition at line 632 of file dataframe.hpp.
|
inline |
Return a typed view of multiple rows.
This function provides the same data as cols() but transposed.
Example:
std::out_of_range | If any of the columns is not in the dataframe. |
Definition at line 680 of file dataframe.hpp.