| Signature | Description | Parameters |
|---|---|---|
template<comparable T, typename ... Ts> void remove_above_quantile_data(const char *col_name, double quantile); |
It removes rows greater than the specified quantile of the given column. The row equal to the quantile is not removed. NOTE: Comparison operators (<, >, >=, <= ==) must be well defined for type T. |
T: Type of the named column Ts: The list of types for all columns. A type should be specified only once col_name: Name of the data column quantile: quantile specified as fraction. For example, 0.35 for 35% quantile |
template<comparable T, typename ... Ts> void remove_below_quantile_data(const char *col_name, double quantile); |
It removes rows smaller than the specified quantile of the given column. The row equal to the quantile is not removed. NOTE: Comparison operators (<, >, >=, <= ==) must be well defined for type T. |
T: Type of the named column Ts: The list of types for all columns. A type should be specified only once col_name: Name of the data column quantile: quantile specified as fraction. For example, 0.35 for 35% quantile |
static void test_remove_above_quantile_data() { std::cout << "\nTesting remove_above_quantile_data( ) ..." << std::endl; StlVecType<unsigned long> idx = { 123450, 123451, 123452, 123453, 123454, 123455, 123456, 123457, 123458, 123459, 123460, 123461, 123462, 123463 }; StlVecType<double> d1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; StlVecType<double> d2 = { 8, 9, 10, 11, 12, 13, 14, 20, 22, 23, 30, 31, 32, 1.89 }; StlVecType<double> d3 = { 15, 16, 15, 18, 19, 16, 21, 0.34, 1.56, 0.34, 2.3, 0.34, 19.0, 10 }; StlVecType<int> i1 = { 22, 23, 24, 25, 99 }; MyDataFrame df; df.load_data(std::move(idx), std::make_pair("col_1", d1), std::make_pair("col_2", d2), std::make_pair("col_3", d3), std::make_pair("col_4", i1)); MyDataFrame df2 = df; auto lbd = [](const unsigned long &, const double &val) -> bool { return (true); }; auto view = df2.get_view_by_sel<double, decltype(lbd), double, int>("col_1", lbd); df.remove_above_quantile_data<double, int, double>("col_3", 0.45); view.remove_above_quantile_data<double, int, double>("col_3", 0.45); StlVecType<unsigned long> index = { 123457, 123458, 123459, 123460, 123461, 123463 }; StlVecType<double> col_1 = { 8, 9, 10, 11, 12, 14 }; StlVecType<double> col_2 = { 20, 22, 23, 30, 31, 1.89 }; StlVecType<double> col_3 = { 0.34, 1.56, 0.34, 2.3, 0.34, 10 }; StlVecType<int> col_4 = { 0, 0, 0, 0, 0, 0 }; assert(df.get_index() == index); assert(df.get_column<double>("col_1") == col_1); assert(df.get_column<double>("col_2") == col_2); assert(df.get_column<double>("col_3") == col_3); assert(df.get_column<int>("col_4") == col_4); } // ----------------------------------------------------------------------------- static void test_remove_below_quantile_data() { std::cout << "\nTesting remove_below_quantile_data( ) ..." << std::endl; StlVecType<unsigned long> idx = { 123450, 123451, 123452, 123453, 123454, 123455, 123456, 123457, 123458, 123459, 123460, 123461, 123462, 123463 }; StlVecType<double> d1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; StlVecType<double> d2 = { 8, 9, 10, 11, 12, 13, 14, 20, 22, 23, 30, 31, 32, 1.89 }; StlVecType<double> d3 = { 15, 16, 15, 18, 19, 16, 21, 0.34, 1.56, 0.34, 2.3, 0.34, 19.0, 10 }; StlVecType<int> i1 = { 22, 23, 24, 25, 99 }; MyDataFrame df; df.load_data(std::move(idx), std::make_pair("col_1", d1), std::make_pair("col_2", d2), std::make_pair("col_3", d3), std::make_pair("col_4", i1)); MyDataFrame df2 = df; auto lbd = [](const unsigned long &, const double &val) -> bool { return (true); }; auto view = df2.get_view_by_sel<double, decltype(lbd), double, int>("col_1", lbd); df.remove_below_quantile_data<double, int, double>("col_3", 0.45); view.remove_below_quantile_data<double, int, double>("col_3", 0.45); StlVecType<unsigned long> index = { 123450, 123451, 123452, 123453, 123454, 123455, 123456, 123462 }; StlVecType<double> col_1 = { 1, 2, 3, 4, 5, 6, 7, 13 }; StlVecType<double> col_2 = { 8, 9, 10, 11, 12, 13, 14, 32 }; StlVecType<double> col_3 = { 15, 16, 15, 18, 19, 16, 21, 19 }; StlVecType<int> col_4 = { 22, 23, 24, 25, 99, 0, 0, 0 }; assert(df.get_index() == index); assert(df.get_column<double>("col_1") == col_1); assert(df.get_column<double>("col_2") == col_2); assert(df.get_column<double>("col_3") == col_3); assert(df.get_column<int>("col_4") == col_4); }