Signature | Description | Parameters |
---|---|---|
template<typename T> std::size_t append_column(const char *name, const T &val, nan_policy padding = nan_policy::pad_with_nans); |
It appends val to the end of the named data column. If data column doesn't exist, it throws an exception. Returns number of items loaded |
T: Type of the named data column name: Name of the column padding: If true, it pads the data column with nan, if it is shorter than the index column. |
template<typename ITR> std::size_t append_column(const char *name, Index2D<const ITR &> range, nan_policy padding = nan_policy::pad_with_nans); |
It appends the range begin to end to the end of the named data column. If data column doesn't exist, it throws an exception. Returns number of items loaded |
ITR: Type of the iterator name: Name of the column range: The begin and end iterators for data padding: If true, it pads the data column with nan, if it is shorter than the index column. |
MyDataFrame df; std::vector<int> &col0 = df.create_column<int>(static_cast<const char *>("col_name")); std::vector<int> intvec = { 1, 2, 3, 4, 5 }; std::vector<double> dblvec = { 1.2345, 2.2345, 3.2345, 4.2345, 5.2345 }; std::vector<double> dblvec2 = { 0.998, 0.3456, 0.056, 0.15678, 0.00345, 0.923, 0.06743, 0.1 }; std::vector<std::string> strvec = { "Col_name", "Col_name", "Col_name", "Col_name", "Col_name" }; std::vector<unsigned long> ulgvec = { 1UL, 2UL, 3UL, 4UL, 5UL, 8UL, 7UL, 6UL }; std::vector<unsigned long> xulgvec = ulgvec; MyDataFrame::size_type rc = df.load_data(std::move(ulgvec), std::make_pair("int_col", intvec), std::make_pair("dbl_col", dblvec), std::make_pair("dbl_col_2", dblvec2), std::make_pair("str_col", strvec), std::make_pair("ul_col", xulgvec)); df.load_index(ulgvec.begin(), ulgvec.end()); df.load_column<int>("int_col", { intvec.begin(), intvec.end() }, nan_policy::pad_with_nans); df.load_column<std::string>("str_col", { strvec.begin(), strvec.end() }, nan_policy::pad_with_nans); df.load_column<double>("dbl_col", { dblvec.begin(), dblvec.end() }, nan_policy::pad_with_nans); df.load_column<double>("dbl_col_2", { dblvec2.begin(), dblvec2.end() }, nan_policy::dont_pad_with_nans); df.append_column<std::string>("str_col", "Additional column"); df.append_column("dbl_col", 10.56);