|
opynsim
Unofficial C++ Documentation
|
Represents a sequence of Series with optional associated metadata.
More...
#include <data_frame.h>
Public Types | |
| using | value_type = Series |
| using | size_type = size_t |
| using | const_reference = const value_type & |
| using | const_iterator = std::vector< Series >::const_iterator |
Public Member Functions | |
| DataFrame ()=default | |
Constructs an empty DataFrame. | |
| DataFrame (std::vector< std::string > column_names, std::vector< std::vector< double > > column_data, std::unordered_map< std::string, std::string > attrs={}) | |
| DataFrame (std::vector< Series > series, std::unordered_map< std::string, std::string > attrs={}) | |
Constructs a DataFrame with the given series. | |
| bool | operator== (const DataFrame &) const |
| std::vector< std::string > | columns () const |
Returns this DataFrame's column labels. | |
| std::tuple< size_t, size_t > | shape () const |
Returns the shape (rows, columns) of this DataFrame. | |
| size_t | height () const |
Returns the number of rows in *this. | |
| size_t | width () const |
Returns the number of Series (columns) in *this. Equivalent to size(). | |
| std::unordered_map< std::string, std::string > | attrs () const |
Returns this DataFrame's metadata (e.g. header key-values). | |
| void | set_attrs (std::unordered_map< std::string, std::string > new_attrs) |
Sets the attrs of this DataFrame to new_attrs. | |
| bool | has_attr (const std::string &key) const |
Returns true if *this has a metadata entry with a key of key. | |
| std::optional< std::string > | get_attr (const std::string &key) const |
| const_reference | operator[] (std::string_view name) const |
| const_reference | operator[] (size_type pos) const |
Returns a reference to the nth series at pos in *this (by-column). | |
| size_type | size () const |
Returns the number of Series (columns) in *this. | |
| bool | empty () const |
Returns true if *this contains no Series, false otherwise. | |
| const_iterator | begin () const |
Returns an iterator to the first Series of *this. | |
| const_iterator | end () const |
Returns an iterator past the last Series of *this. | |
| const_iterator | find (std::string_view name) const |
| DataFrame | with_series (Series series) const |
Represents a sequence of Series with optional associated metadata.
| using opyn::DataFrame::const_iterator = std::vector<Series>::const_iterator |
| using opyn::DataFrame::const_reference = const value_type& |
| using opyn::DataFrame::size_type = size_t |
| using opyn::DataFrame::value_type = Series |
|
default |
Constructs an empty DataFrame.
|
explicit |
Constructs a DataFrame with the given column names and data.
Throws an exception if column_names.size() != column_data.size() or any entries in column_data have a different size.
|
explicit |
Constructs a DataFrame with the given series.
| std::unordered_map< std::string, std::string > opyn::DataFrame::attrs | ( | ) | const |
Returns this DataFrame's metadata (e.g. header key-values).
|
inline |
Returns an iterator to the first Series of *this.
| std::vector< std::string > opyn::DataFrame::columns | ( | ) | const |
Returns this DataFrame's column labels.
|
inline |
Returns true if *this contains no Series, false otherwise.
|
inline |
Returns an iterator past the last Series of *this.
| const_iterator opyn::DataFrame::find | ( | std::string_view | name | ) | const |
| std::optional< std::string > opyn::DataFrame::get_attr | ( | const std::string & | key | ) | const |
Returns the value of the metadata entry with key key, or std::nullopt if the metadata contains no such entry.
| bool opyn::DataFrame::has_attr | ( | const std::string & | key | ) | const |
Returns true if *this has a metadata entry with a key of key.
| size_t opyn::DataFrame::height | ( | ) | const |
Returns the number of rows in *this.
| bool opyn::DataFrame::operator== | ( | const DataFrame & | ) | const |
Returns true all members of lhs compare equivalent to rhs.
Note: This operator confirms to IEEE 754 and C++'s regular type invariants, which means identity checks are non-reflexive for special values. Therefore, if either lhs or rhs contains NaN values, this operator will return false.
|
inline |
Returns a reference to the nth series at pos in *this (by-column).
| const_reference opyn::DataFrame::operator[] | ( | std::string_view | name | ) | const |
Returns the Series in *this that has the name name.
Throws a std::exception if name cannot be found.
| void opyn::DataFrame::set_attrs | ( | std::unordered_map< std::string, std::string > | new_attrs | ) |
Sets the attrs of this DataFrame to new_attrs.
| std::tuple< size_t, size_t > opyn::DataFrame::shape | ( | ) | const |
Returns the shape (rows, columns) of this DataFrame.
| size_t opyn::DataFrame::width | ( | ) | const |
Returns a new DataFrame with series merged into it.
name of series dictates whether the merge appends series to the end of *this or overwrites an existing Series in *this with the same name.size of series must match the height of *this, or *this must be empty. Otherwise, a std::exception is thrown.Series will always have empty attrs. It is up to the caller to decide how to propagate metadata.