DtypeOverride#

class pandas::DtypeOverride#

pandas C++ class.

Example#

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

// Use DtypeOverride
DtypeOverride obj;
// ... operations ...

I/O#

Signature

Return Type

Location

Example

std::string to_string() const

std::string

pd_dtype_override.h:51

View

Other Methods#

Signature

Return Type

Location

Example

static DtypeOverride parse(std::string_view label)

static DtypeOverride

pd_dtype_override.h:50

View

Code Examples#

The following examples are extracted from the test suite.

to_string (pd_test_1_all.cpp:2693)
2683        pandas::PeriodArray arr_m(std::vector<std::string>{
2684            "2020-01",
2685            "NaT",
2686            "2025-06"
2687        }, "M");
2688
2689        // Year
2690        auto years = arr_m.year();
2691        auto y0 = years[0];
2692        if (!y0.has_value() || y0.value() != 2020) {
2693            std::cout << "  [FAIL] : year[0] should be 2020, got " << (y0.has_value() ? std::to_string(y0.value()) : "NA") << std::endl;
2694            throw std::runtime_error("pd_test_period_array_year_month_quarter failed: year[0]");
2695        }
2696
2697        auto y1 = years[1];
2698        if (y1.has_value()) {
2699            std::cout << "  [FAIL] : year[1] should be NA (NaT)" << std::endl;
2700            throw std::runtime_error("pd_test_period_array_year_month_quarter failed: year[1] should be NA");
2701        }
2702
2703        auto y2 = years[2];
parse (pd_test_2_all.cpp:4314)
4304                throw std::runtime_error("ExcelFile basic: expected sheet 'Data', got '" + names[0] + "'");
4305            }
4306
4307            xlsx.close();
4308            std::remove("temp/test_excelfile.xlsx");
4309
4310            std::cout << " -> tests passed" << std::endl;
4311        }
4312
4313        void pd_test_excel_file_parse() {
4314            std::cout << "========= ExcelFile.parse() ========================";
4315
4316            try {
4317                // Create test file
4318                std::map<std::string, std::vector<int>> data = {{"X", {10, 20, 30}}, {"Y", {40, 50, 60}}};
4319                pandas::DataFrame df(data);
4320                df.to_excel("temp/test_parse.xlsx", "Sheet1");
4321
4322                pandas::ExcelFile xlsx("temp/test_parse.xlsx");
4323
4324                // Check sheet names