| Signature | Description | Parameters |
|---|---|---|
template<typename ... Ts> DataFrame<DateTime, H> get_data_on_days(const std::vector<DT_WEEKDAY> &days) const; |
This selects the rows using the index column that happen on the specified days of the week. It returns another DataFrame with selected data indexed by DateTime. Self is unchanged. NOTE: The index column type must be DateTime or it won't compile |
Ts: List all the types of all data columns. A type should be specified in the list only once. days: List of specified days |
template<typename ... Ts> PtrView get_view_on_days(const std::vector<DT_WEEKDAY> &days); |
It behaves like get_data_on_days(), but it returns a View. A view is a DataFrame that is a reference to the original DataFrame. So if you modify anything in the view the original DataFrame will also be modified. NOTE: There are certain operations that you cannot do with a view. For example, you cannot add/delete columns, etc. |
Ts: List all the types of all data columns. A type should be specified in the list only once. days: List of specified days |
template<typename ... Ts> ConstPtrView get_view_on_days(const std::vector<DT_WEEKDAY> &days) 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. |
Ts: List all the types of all data columns. A type should be specified in the list only once. days: List of specified days |
static void test_get_data_on_days() { std::cout << "\nTesting get_data_on_days( ) ..." << std::endl; DTDataFrame df; try { df.read("DT_Intraday.csv", io_format::csv2); } catch (const DataFrameError &ex) { std::cout << ex.what() << std::endl; } const auto result = df.get_view_on_days<double, long>({ DT_WEEKDAY::MON, DT_WEEKDAY::FRI }); assert(result.get_index().size() == 2861); assert(result.get_index()[0].date() == 19861117); assert(result.get_index()[100].date() == 19861124); assert(result.get_index()[1000].date() == 19870202); assert(result.get_index()[2860].date() == 19870622); assert(result.get_column<double>("dbl value").size() == 2861); assert(result.get_column<double>("dbl value")[0] == 32.5); assert(result.get_column<double>("dbl value")[100] == 195.5); assert(result.get_column<double>("dbl value")[1000] == 1771.5); assert(result.get_column<double>("dbl value")[2860] == 4973.5); assert(result.get_column<long>("lng value").size() == 2861); assert(result.get_column<long>("lng value")[0] == 650); assert(result.get_column<long>("lng value")[100] == 3910); assert(result.get_column<long>("lng value")[1000] == 35430); assert(result.get_column<long>("lng value")[2860] == 99470); }