| Signature | Description | Parameters |
|---|---|---|
template<typename ... Ts> DataFrame<DateTime, H> get_data_at_times(DateTime::HourType hour, // 24 hour DateTime::MinuteType minute = 0, DateTime::SecondType second = 0, DateTime::MillisecondType msec = 0) const; |
This selects the rows using the index column at specified time. 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. hour: Specified hour minute: Specified minute second: Specified second msec: Specified milli-second |
template<typename ... Ts> PtrView get_view_at_times(DateTime::HourType hour, // 24 hour DateTime::MinuteType minute = 0, DateTime::SecondType second = 0, DateTime::MillisecondType msec = 0); |
It behaves like get_data_at_times(), 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. hour: Specified hour minute: Specified minute second: Specified second msec: Specified milli-second |
template<typename ... Ts> PtrView get_view_at_times(DateTime::HourType hour, // 24 hour DateTime::MinuteType minute = 0, DateTime::SecondType second = 0, DateTime::MillisecondType msec = 0); |
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. hour: Specified hour minute: Specified minute second: Specified second msec: Specified milli-second |
static void test_get_data_at_times() { std::cout << "\nTesting load_get_data_at_times( ) ..." << 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_at_times<double, long>(16, 30); assert(result.get_index().size() == 7); assert(result.get_index()[0].date() == 19861115); assert(result.get_index()[1].date() == 19861214); assert(result.get_index()[6].date() == 19870613); assert(result.get_index()[5].date() == 19870508); assert(result.get_column<double>("dbl value").size() == 7); assert(result.get_column<double>("dbl value")[0] == 4.0); assert(result.get_column<double>("dbl value")[1] == 655.5); assert(result.get_column<double>("dbl value")[6] == 4767.0); assert(result.get_column<double>("dbl value")[5] == 3935.5); assert(result.get_column<long>("lng value").size() == 7); assert(result.get_column<long>("lng value")[0] == 80); assert(result.get_column<long>("lng value")[1] == 13110); assert(result.get_column<long>("lng value")[6] == 95340); assert(result.get_column<long>("lng value")[5] == 78710); }