70 std::vector<std::string>,
71 std::vector<std::vector<std::variant<int64_t, long double, std::string>>>>
75 std::vector<std::variant<int64_t, long double, std::string>>>
80 typedef std::pair<std::vector<std::string>,
81 std::vector<std::vector<std::string>>>
85 typedef std::pair<std::vector<int64_t>, std::vector<std::vector<int64_t>>>
89 typedef std::pair<std::vector<long double>,
90 std::vector<std::vector<long double>>>
113 headers_ = std::vector<std::string>();
118 for (
const auto &header :
headers_) {
119 std::cout << header <<
"\t";
121 std::cout << std::endl;
124 for (
const auto &row :
data_) {
125 for (
const auto &cell : row) {
127 if (std::holds_alternative<int64_t>(cell)) {
128 std::cout << std::get<int64_t>(cell);
129 }
else if (std::holds_alternative<long double>(cell)) {
130 std::cout << std::get<long double>(cell);
131 }
else if (std::holds_alternative<std::string>(cell)) {
132 std::cout << std::get<std::string>(cell);
137 std::cout << std::endl;
153 std::vector<std::string> columns = {});
156 std::vector<std::string> columns);
173 std::vector<std::string> columns = {});
184 std::vector<std::string> objs = {});
189 void drop(std::vector<std::string> column_name);
200 bool extract_year =
true,
201 bool extract_month =
true,
202 bool extract_time =
false);
210 void sort(
const std::vector<std::string> &sort_columns,
211 bool ascending =
true);
221 std::vector<DataTableStr>
222 group_by(std::vector<std::string> group_by_columns);
230 first(
const std::vector<gpmp::core::DataTableStr> &groups)
const;
DataTableStr json_read(std::string filename, std::vector< std::string > objs={})
Reads a JSON file and returns a DataTableStr parses JSON files and stores all data as strings.
std::vector< DataTableStr > group_by(std::vector< std::string > group_by_columns)
Groups the data by specified columns.
DataType inferType(const std::vector< std::string > &column)
std::vector< std::vector< std::string > > data_
DataTableStr csv_read(std::string filename, std::vector< std::string > columns)
DataTableStr first(const std::vector< gpmp::core::DataTableStr > &groups) const
Gets the first element of each created group.
void describe()
Displays some information about the DataTable.
void csv_write()
Write DataTable to a CSV file.
void info()
Displays data types and null vals for each column.
DataTableStr datetime(std::string column_name, bool extract_year=true, bool extract_month=true, bool extract_time=false)
Extracts date and time components from a timestamp column.
TableType native_type(const std::vector< std::string > &skip_columns={})
Converts DataTable column's rows to their native types. Since the existing DataTable read/load relate...
void sort(const std::vector< std::string > &sort_columns, bool ascending=true)
Sorts the rows of the DataTable based on specified columns.
std::vector< std::string > headers_
DataTableStr original_data_
void drop(std::vector< std::string > column_name)
Drop specified rows from a DataTable.
void display(std::pair< std::vector< T >, std::vector< std::vector< T >>> data, bool display_all=false)
Sort a DataTable based on a specified column.
DataTableInt str_to_int(DataTableStr src)
Converts a DataTableStr to a DataTableInt.
DataTableDouble str_to_double(DataTableStr src)
Converts a DataTableStr to a DataTableDouble.
std::vector< std::string > new_headers_
DataTableStr tsv_read(std::string filename, std::vector< std::string > columns={})
Reads a TSV file and returns a DataTableStr parses TSV files and stores all data as strings.
void display(bool display_all=false)
Overload function for display() defaults to displaying what is currently stored in a DataTable object...
TableType csv_read_new(std::string filename, std::vector< std::string > columns={})
Reads a CSV file and returns a DataTableStr parses CSV files and stores all data as strings.
DataTable()
DataTable constructor. Initializes column & row storage.
std::pair< std::vector< long double >, std::vector< std::vector< long double > > > DataTableDouble
std::pair< std::vector< std::string >, std::vector< std::vector< std::string > > > DataTableStr
std::pair< std::vector< std::string >, std::vector< std::vector< std::variant< int64_t, long double, std::string > > > > TableType
DataType
enum for representing different data types
std::pair< std::vector< int64_t >, std::vector< std::vector< int64_t > > > DataTableInt
std::vector< std::vector< std::variant< int64_t, long double, std::string > > > MixedType
The source C++ openGPMP namespace.