DtypeOverride ============= .. cpp:class:: pandas::DtypeOverride pandas C++ class. Example ------- .. code-block:: cpp #include using namespace pandas; // Use DtypeOverride DtypeOverride obj; // ... operations ... I/O --- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``std::string to_string() const`` - std::string - pd_dtype_override.h:51 - :ref:`View ` Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``static DtypeOverride parse(std::string_view label)`` - static DtypeOverride - pd_dtype_override.h:50 - :ref:`View ` Code Examples ------------- The following examples are extracted from the test suite. .. _example-dtypeoverride-to_string-0: .. dropdown:: to_string (pd_test_1_all.cpp:2693) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 2683 :emphasize-lines: 11 pandas::PeriodArray arr_m(std::vector{ "2020-01", "NaT", "2025-06" }, "M"); // Year auto years = arr_m.year(); auto y0 = years[0]; if (!y0.has_value() || y0.value() != 2020) { std::cout << " [FAIL] : year[0] should be 2020, got " << (y0.has_value() ? std::to_string(y0.value()) : "NA") << std::endl; throw std::runtime_error("pd_test_period_array_year_month_quarter failed: year[0]"); } auto y1 = years[1]; if (y1.has_value()) { std::cout << " [FAIL] : year[1] should be NA (NaT)" << std::endl; throw std::runtime_error("pd_test_period_array_year_month_quarter failed: year[1] should be NA"); } auto y2 = years[2]; .. _example-dtypeoverride-parse-1: .. dropdown:: parse (pd_test_2_all.cpp:4314) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 4304 :emphasize-lines: 11 throw std::runtime_error("ExcelFile basic: expected sheet 'Data', got '" + names[0] + "'"); } xlsx.close(); std::remove("temp/test_excelfile.xlsx"); std::cout << " -> tests passed" << std::endl; } void pd_test_excel_file_parse() { std::cout << "========= ExcelFile.parse() ========================"; try { // Create test file std::map> data = {{"X", {10, 20, 30}}, {"Y", {40, 50, 60}}}; pandas::DataFrame df(data); df.to_excel("temp/test_parse.xlsx", "Sheet1"); pandas::ExcelFile xlsx("temp/test_parse.xlsx"); // Check sheet names