| Signature | Description | Parameters |
|---|---|---|
template<arithmetic T, typename ... Ts> DataFrame get_data_by_stdev(const char *col_name, T high_stdev, T low_stdev) const; |
This calculates the mean and standard deviation of the named column. It returns a new DataFrame that contains all the data where named column data is between high_stdev and low_stdev from the mean. Self is unchanged. NOTE Type T must support arithmetic operations |
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 high_stdev: All data rows below this will be returned. low_stdev: All data rows above this will be returned. |
template<arithmetic T, typename ... Ts> PtrView get_view_by_stdev(const char *col_name, T high_stdev, T low_stdev); |
This is identical to above get_data_by_stdev(), but:
|
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 high_stdev: All data rows below this will be returned. low_stdev: All data rows above this will be returned. |
template<arithmetic T, typename ... Ts> ConstPtrView get_view_by_stdev(const char *col_name, T high_stdev, T low_stdev) const; |
Same as above view, but it returns a const view. You can not change data in const views. But if the data is changed in the original DataFrame or through another view, it is reflected in the const view. |
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 high_stdev: All data rows below this will be returned. low_stdev: All data rows above this will be returned. |
static void test_get_data_by_stdev() { std::cout << "\nTesting get_data_by_stdev( ) ..." << std::endl; typedef StdDataFrame64<std::string> StrDataFrame; StrDataFrame df; try { df.read("SHORT_IBM.dat", io_format::binary); } catch (const DataFrameError &ex) { std::cout << ex.what() << std::endl; } StrDataFrame df2 = df; auto lbd = [](const std::string &, const double &) -> bool { return (true); }; auto view = df2.get_view_by_sel<double, decltype(lbd), double, long>("IBM_Open", lbd); auto result_df = df.get_data_by_stdev <double, double, long>("IBM_Close", 0.1, -0.4); auto result_view = view.get_view_by_stdev<double, double, long>("IBM_Close", 0.1, -0.4); assert(result_df.get_index().size() == 379); assert(result_view.get_index().size() == 379); assert(result_view.get_column<double>("IBM_Open").size() == 379); assert(result_view.get_column<long>("IBM_Volume").size() == 379); assert(result_df.get_column<double>("IBM_Low").size() == 379); assert(result_df.get_column<long>("IBM_Volume").size() == 379); assert(result_df.get_index()[300] == "2018-08-23"); assert(result_view.get_index()[300] == "2018-08-23"); assert(result_df.get_index()[101] == "2016-06-13"); assert(result_view.get_index()[101] == "2016-06-13"); assert(result_view.get_column<double>("IBM_Open")[45] == 141.740005); assert(result_df.get_column<double>("IBM_Open")[45] == 141.740005); assert(result_df.get_column<long>("IBM_Volume")[230] == 4413200); assert(result_view.get_column<long>("IBM_Volume")[230] == 4413200); }