| Signature | Description | Parameters |
|---|---|---|
template<typename T> std::pair<size_type, size_type> fl_valid_index(const char *col_name) const; |
This returns a pair containing the first and last indices of non-NaN/valid values in the requested column. If the column is empty or contains all NaN values, both indices will be zero. |
T: Type of the named column col_name: Name of the column. It can be a data column name or DF_INDEX_COL_NAME |
static void test_fl_valid_index() { std::cout << "\nTesting fl_valid_index( ) ..." << std::endl; const double nval = std::numeric_limits<double>::quiet_NaN(); MyDataFrame df; std::vector<unsigned long> idxvec = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; std::vector<double> dblvec = { 0, 15, -14, 2, 1, 12, 11, 8, 7, 6, 5, 4, 3, 9, 10}; std::vector<double> dblvec2 = { 100, 101, nval, 103, 104, 103.9, 106.55, 106.34, 1.8, nval, 112, 111.5, 114, nval, nval}; std::vector<double> dblempty { }; std::vector<double> allnan = { nval, nval, nval, nval, nval, nval, nval, nval, nval, nval, nval, nval, nval, nval, nval}; std::vector<std::string> strvec = { "", "bb", "cc", "ww", "", "ff", "gg", "hh", "ii", "jj", "kk", "ll", "mm", "nn", "" }; df.load_data(std::move(idxvec), std::make_pair("dbl_col", dblvec), std::make_pair("dbl_col_2", dblvec2), std::make_pair("Empty Col", dblempty), std::make_pair("All NaN Col", allnan), std::make_pair("str_col", strvec)); const auto res1 = df.fl_valid_index<double>("dbl_col"); assert(res1.first == 0); assert(res1.second == 14); const auto res2 = df.fl_valid_index<double>("dbl_col_2"); assert(res2.first == 0); assert(res2.second == 12); const auto res3 = df.fl_valid_index<double>("Empty Col"); assert(res3.first == 0); assert(res3.second == 0); const auto res4 = df.fl_valid_index<double>("All NaN Col"); assert(res4.first == 0); assert(res4.second == 0); const auto res5 = df.fl_valid_index<std::string>("str_col"); assert(res5.first == 1); assert(res5.second == 13); }