UnsortedIndexError#

class pandas::UnsortedIndexError#

pandas C++ class.

Example#

#include <pandas/pandas.h>
using namespace pandas;

// Create UnsortedIndexError
UnsortedIndexError<int64_t> idx({1, 2, 3}, "my_index");
size_t len = idx.size();

Constructors#

Signature

Location

Example

explicit UnsortedIndexError(const std::string& msg) : std::runtime_error(msg)

pd_exceptions.h:91

View

explicit UnsortedIndexError(const char\* msg) : std::runtime_error(msg)

pd_exceptions.h:92

View

Code Examples#

The following examples are extracted from the test suite.

UnsortedIndexError (pd_test_5_all.cpp:73561)
73551    pandas_tests::check(
73552        has_no_trailing_ws_ui(
73553            pandas::error_messages::unsorted_index_key_vs_depth(7, 1)),
73554        "case_3.unsorted_index_key_vs_depth_no_trail", local_fail);
73555}
73556
73557void case_4_unsorted_index_error_roundtrip(int& local_fail) {
73558    std::cout << "-- case_4_unsorted_index_error_roundtrip\n";
73559    std::string caught;
73560    try {
73561        throw pandas::UnsortedIndexError(
73562            pandas::error_messages::unsorted_index_key_vs_depth(2, 0));
73563    } catch (const pandas::UnsortedIndexError& e) {
73564        caught = e.what();
73565    }
73566    check_eq_str_ui("case_4.UnsortedIndexError_what_roundtrip",
73567                    "Key length (2) was greater than MultiIndex lexsort depth (0)",
73568                    caught,
73569                    local_fail);
73570}
UnsortedIndexError (pd_test_5_all.cpp:73561)
73551    pandas_tests::check(
73552        has_no_trailing_ws_ui(
73553            pandas::error_messages::unsorted_index_key_vs_depth(7, 1)),
73554        "case_3.unsorted_index_key_vs_depth_no_trail", local_fail);
73555}
73556
73557void case_4_unsorted_index_error_roundtrip(int& local_fail) {
73558    std::cout << "-- case_4_unsorted_index_error_roundtrip\n";
73559    std::string caught;
73560    try {
73561        throw pandas::UnsortedIndexError(
73562            pandas::error_messages::unsorted_index_key_vs_depth(2, 0));
73563    } catch (const pandas::UnsortedIndexError& e) {
73564        caught = e.what();
73565    }
73566    check_eq_str_ui("case_4.UnsortedIndexError_what_roundtrip",
73567                    "Key length (2) was greater than MultiIndex lexsort depth (0)",
73568                    caught,
73569                    local_fail);
73570}