| Signature | Description | Parameters |
|---|---|---|
template<StringOnly T, typename ... Ts> DataFrame remove_data_by_like(const char *name, const char *pattern, bool case_insensitive = false, char esc_char = '\\') const; |
This removes data rows by basic Glob-like pattern matching (also similar to SQL like clause) to filter data in the named column. Each element of the named column is checked against a Glob-like matching logic. Elements that are matched are removed. Globbing rules: '*' Matches any sequence of zero or more characters. '?' Matches exactly one character. [...] Matches one character from the enclosed list of characters. [^...] Matches one character not in the enclosed list. With the [...] and [^...] matching, a ']' character can be included in the list by making it the first character after '[' or '^'. A range of characters can be specified using '-'. Example: "[a-z]" matches any single lower-case letter. To match a '-', make it the last character in the list. Hint: To match '*' or '?', put them in "[]". Like this: abc[*]xyz matches "abc*xyz" only NOTE: If this is called from a PtrView, the data is removed from the view but not from the original DataFrame |
T: Type of the named column. Based on the concept, it can only be either of these types: std::string, VirtualString, const char *, char * Ts: List all the types of all data columns. A type should be specified in the list only once. name: Name of the data column pattern: Glob like pattern to use for matching strings case_insensitive: If true, matching logic ignores case esc_char: Character used for escape |
template<StringOnly T, typename ... Ts> DataFrame remove_data_by_like(const char *name1, const char *name2, const char *pattern1, const char *pattern2, bool case_insensitive = false, char esc_char = '\\') const; |
This does the same function as above remove_data_by_like() but operating on two columns. NOTE: If this is called from a PtrView, the data is removed from the view but not from the original DataFrame |
T: Type of both named columns. Based on the concept, it can only be either of these types: std::string, VirtualString, const char *, char * Ts: List all the types of all data columns. A type should be specified in the list only once. name1: Name of the first data column name2: Name of the second data column pattern1: Glob like pattern to use for matching strings for the first column pattern2: Glob like pattern to use for matching strings for the second column case_insensitive: If true, matching logic ignores case esc_char: Character used for escape |
static void test_remove_data_by_like() { std::cout << "\nTesting remove_data_by_like( ) ..." << std::endl; StlVecType<unsigned long> idxvec = { 1UL, 2UL, 3UL, 10UL, 5UL, 7UL, 8UL, 12UL, 9UL, 12UL, 10UL, 13UL, 10UL, 15UL, 14UL }; StlVecType<unsigned long> idxvec2 = { 1UL, 2UL, 3UL, 10UL, 5UL, 7UL, 8UL, 12UL, 9UL, 12UL, 10UL, 13UL, 10UL, 15UL, 14UL }; StlVecType<std::string> strvec1 = { "345&%$abcM", "!@#$0987^HGTtiff\"", "ABFDTiy", "345&%$abcM", "!@#$0987^HGTtiff\"", "!@#$0987^HGTtiff\"", "345&%$abcM", "!@#$0987^HGTtiff\"", "ABFDTiy", "345&%$abcM", "!@#$0987^HGTtiff\"", "ABFDTiy", "345&%$abcM", "ABFDTiy", "ABFDTiy" }; StlVecType<std::string> strvec2 = { "ABFDTiy", "!@#$0987^HGTtiff\"", "ABFDTiy", "345&%$abcM", "!@#$0987^HGTtiff\"", "ABFDTiy", "!@#$0987^HGTtiff\"", "!@#$0987^HGTtiff\"", "ABFDTiy", "345&%$abcM", "!@#$0987^HGTtiff\"", "ABFDTiy", "345&%$abcM", "ABFDTiy", "ABFDTiy" }; StlVecType<const char *> strvec12 = { "345&%$abcM", "!@#$0987^HGTtiff\"", "ABFDTiy", "345&%$abcM", "!@#$0987^HGTtiff\"", "!@#$0987^HGTtiff\"", "345&%$abcM", "!@#$0987^HGTtiff\"", "ABFDTiy", "345&%$abcM", "!@#$0987^HGTtiff\"", "ABFDTiy", "345&%$abcM", "ABFDTiy", "ABFDTiy" }; StlVecType<const char *> strvec22 = { "ABFDTiy", "!@#$0987^HGTtiff\"", "ABFDTiy", "345&%$abcM", "!@#$0987^HGTtiff\"", "ABFDTiy", "!@#$0987^HGTtiff\"", "!@#$0987^HGTtiff\"", "ABFDTiy", "345&%$abcM", "!@#$0987^HGTtiff\"", "ABFDTiy", "345&%$abcM", "ABFDTiy", "ABFDTiy" }; StlVecType<int> intvec = { 1, 2, 3, 10, 5, 7, 8, 12, 9, 12, 10, 13, 10, 15, 14 }; StlVecType<int> intvec2 = { 1, 2, 3, 10, 5, 7, 8, 12, 9, 12, 10, 13, 10, 15, 14 }; MyDataFrame df1; MyDataFrame df2; df1.load_data(std::move(idxvec), std::make_pair("str column 1", strvec1), std::make_pair("str column 2", strvec2), std::make_pair("int column", intvec)); df2.load_data(std::move(idxvec2), std::make_pair("str column 1", strvec12), std::make_pair("str column 2", strvec22), std::make_pair("int column", intvec2)); df1.remove_data_by_like<std::string, std::string, int>("str column 1", "str column 2", "?*[0-9][0-9][0-9][0-9]?*", "?*[0-9][0-9][0-9][0-9]?*"); assert(df1.get_index().size() == 11); assert(df1.get_index()[2] == 10); assert(df1.get_column<int>("int column")[2] == 10); assert(df1.get_column<std::string>("str column 1").size() == 11); assert(df1.get_column<std::string>("str column 2").size() == 11); assert((df1.get_column<std::string>("str column 1")[0] == "345&%$abcM")); assert((df1.get_column<std::string>("str column 1")[2] == "345&%$abcM")); assert((df1.get_column<std::string>("str column 2")[0] == "ABFDTiy")); assert((df1.get_column<std::string>("str column 2")[2] == "345&%$abcM")); df2.remove_data_by_like<const char *, const char *, int>("str column 1", "?*&%?*"); assert(df2.get_index().size() == 10); assert(df2.get_index()[2] == 5); assert(df2.get_column<int>("int column")[2] == 5); assert(df2.get_column<const char *>("str column 1").size() == 10); assert(df2.get_column<const char *>("str column 2").size() == 10); assert(! strcmp(df2.get_column<const char *>("str column 1")[0], "!@#$0987^HGTtiff\"")); assert(! strcmp(df2.get_column<const char *>("str column 1")[2], "!@#$0987^HGTtiff\"")); assert(! strcmp(df2.get_column<const char *>("str column 2")[0], "!@#$0987^HGTtiff\"")); assert(! strcmp(df2.get_column<const char *>("str column 2")[2], "!@#$0987^HGTtiff\"")); }