HDF5Store#

class pandas::HDF5Store#

pandas C++ class.

Example#

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

// Use HDF5Store
HDF5Store obj;
// ... operations ...

Constructors#

Signature

Location

Example

explicit HDF5Store( const std::string& path, const std::string& mode = "a", std::optional<int> complevel = std::nullopt, std::optional<std::string> complib = std::nullopt, bool fletcher32 = false)

pd_hdf5.h:74

HDF5Store(const HDF5Store&) = delete

pd_hdf5.h:111

HDF5Store(HDF5Store&&) = default

pd_hdf5.h:115

Construction#

Signature

Return Type

Location

Example

HighFive::Group create_group(const std::string& name)

HighFive::Group

pd_hdf5.h:188

View

Indexing / Selection#

Signature

Return Type

Location

Example

HighFive::Group get_group(const std::string& name)

HighFive::Group

pd_hdf5.h:198

View

Combining#

Signature

Return Type

Location

Example

void append( const std::string& key, const DataFrame& value, std::optional<std::string> format = std::nullopt, std::optional<std::vector<int>> axes = std::nullopt, bool index = true, bool append_mode = true, std::optional<std::vector<std::string>> data_columns = std::nullopt, std::optional<std::map<std::string, int>> min_itemsize = std::nullopt, std::optional<std::string> nan_rep = std::nullopt, std::optional<int64_t> chunksize = std::nullopt, std::optional<int64_t> expectedrows = std::nullopt, bool dropna = false, bool track_times = true)

void

pd_hdf5.h:670

View

Iteration#

Signature

Return Type

Location

Example

std::vector<std::string> keys() const

std::vector<std::string>

pd_hdf5.h:173

View

std::vector<std::string> keys(const std::string& group_name) const

std::vector<std::string>

pd_hdf5.h:180

View

std::vector<std::string> keys_pandas(const std::string& include = "pandas") const

std::vector<std::string>

pd_hdf5.h:369

View

Type Checking#

Signature

Return Type

Location

Example

bool is_open() const

bool

pd_hdf5.h:336

View

Other Methods#

Signature

Return Type

Location

Example

void close()

void

pd_hdf5.h:328

View

bool contains(const std::string& key) const

bool

pd_hdf5.h:352

View

bool exists(const std::string& name) const

bool

pd_hdf5.h:166

View

HighFive::File& file()

HighFive::File&

pd_hdf5.h:317

View

const HighFive::File& file() const

const HighFive::File&

pd_hdf5.h:318

View

std::string filename() const

std::string

pd_hdf5.h:344

View

complib_(complib), fletcher32_(fletcher32)

complib_(complib),

pd_hdf5.h:81

void flush()

void

pd_hdf5.h:310

std::vector<std::string> groups() const

std::vector<std::string>

pd_hdf5.h:520

View

bool has_attribute(const std::string& dataset_name, const std::string& attr_name)

bool

pd_hdf5.h:279

View

std::string info() const

std::string

pd_hdf5.h:483

View

std::string path() const

std::string

pd_hdf5.h:305

View

void put( const std::string& key, const DataFrame& value, std::optional<std::string> format = std::nullopt, bool index = true, bool append_mode = false, std::optional<std::vector<std::string>> data_columns = std::nullopt, std::optional<std::string> encoding = std::nullopt, bool dropna = false, bool track_times = true)

void

pd_hdf5.h:632

std::string read_attribute(const std::string& dataset_name, const std::string& attr_name)

std::string

pd_hdf5.h:232

View

T read_attribute_as(const std::string& dataset_name, const std::string& attr_name)

T

pd_hdf5.h:256

View

std::vector<std::vector<T>> read_dataset_2d(const std::string& name)

std::vector<std::vector<T>>

pd_hdf5.h:156

View

void remove(const std::string& name)

void

pd_hdf5.h:296

View

void remove_pandas( const std::string& key, [[maybe_unused]] std::optional<std::string> where = std::nullopt, [[maybe_unused]] std::optional<int64_t> start = std::nullopt, [[maybe_unused]] std::optional<int64_t> stop = std::nullopt)

void

pd_hdf5.h:462

View

size_t size() const

size_t

pd_hdf5.h:360

View

std::ifstream test(path)

std::ifstream

pd_hdf5.h:93

View

walk(const std::string& where = "/") const

pd_hdf5.h:558

View

walk_fn(subgroup, full_path)

pd_hdf5.h:584

walk_fn(subgroup, full_path)

pd_hdf5.h:611

walk_fn(grp, where)

pd_hdf5.h:616

walk_group(subgroup, full_path)

pd_hdf5.h:409

walk_group(subgroup, full_path)

pd_hdf5.h:449

walk_group(subgroup, full_path)

pd_hdf5.h:532

walk_group(subgroup, full_path)

pd_hdf5.h:545

void write_attribute(const std::string& dataset_name, const std::string& attr_name, const std::string& value)

void

pd_hdf5.h:205

View

void write_attribute(const std::string& dataset_name, const std::string& attr_name, const T& value)

void

pd_hdf5.h:219

View

void write_dataset(const std::string& name, const std::vector<T>& data)

void

pd_hdf5.h:122

View

void write_dataset_2d(const std::string& name, const std::vector<std::vector<T>>& data)

void

pd_hdf5.h:133

View

Code Examples#

The following examples are extracted from the test suite.

create_group (pd_test_3_all.cpp:19278)
19268    std::remove(path.c_str());
19269    std::cout << "  test_write_read_2d passed\n";
19270}
19271
19272void test_groups() {
19273    std::string path = "test_hdf5_groups.h5";
19274
19275    {
19276        pandas::HDF5Store store(path, "w");
19277        HighFive::Group hdf_grp = store.create_group("dataframe1");
19278        hdf_grp.createDataSet("col_a", std::vector<int>{1, 2, 3});
19279        hdf_grp.createDataSet("col_b", std::vector<double>{1.1, 2.2, 3.3});
19280    }
19281
19282    {
19283        pandas::HDF5Store store(path, "r");
19284        auto keys = store.keys();
19285        if (keys.size() != 1 || keys[0] != "dataframe1")
19286            throw std::runtime_error("test_groups: root keys mismatch");
get_group (pd_test_2_all.cpp:20487)
20477        ++g_fail;
20478    }
20479}
20480
20481static bool approx_eq(double a, double b, double tol = 1e-9) {
20482    if (std::isnan(a) && std::isnan(b)) return true;
20483    return std::abs(a - b) < tol;
20484}
20485
20486// =====================================================================
20487// Test: get_group() with exclude_cols removes groupby columns
20488// =====================================================================
20489
20490void pd_test_groupby_apply_get_group_exclude() {
20491    std::cout << "  -- pd_test_groupby_apply_get_group_exclude --" << std::endl;
20492
20493    pandas::DataFrame df;
20494    df.add_column("key", std::vector<std::string>{"a", "a", "b", "b"});
20495    df.add_column("val1", std::vector<double>{1.0, 2.0, 3.0, 4.0});
20496    df.add_column("val2", std::vector<double>{10.0, 20.0, 30.0, 40.0});
append (pd_test_1_all.cpp:10650)
10640    std::cout << "========= append =========================";
10641
10642    // Use same categories for both arrays (required by CategoricalArray::concat)
10643    std::vector<std::string> cats = {"a", "b", "c", "d"};
10644    pandas::CategoricalArray arr1({"a", "b"}, cats);
10645    pandas::CategoricalIndex idx1(arr1);
10646
10647    pandas::CategoricalArray arr2({"c", "d"}, cats);
10648    pandas::CategoricalIndex idx2(arr2);
10649
10650    auto appended = idx1.append(idx2);
10651
10652    bool passed = (appended.size() == 4);
10653    if (!passed) {
10654        std::cout << "  [FAIL] : in pd_test_extension_index_append() : append check failed" << std::endl;
10655        throw std::runtime_error("pd_test_extension_index_append failed");
10656    }
10657
10658    std::cout << " -> tests passed" << std::endl;
10659}
keys (pd_test_1_all.cpp:16319)
16309            }
16310
16311            // Test default value
16312            passed = attrs.get<int>("missing", 99) == 99;
16313            if (!passed) {
16314                std::cout << "  [FAIL] : in pd_test_ndframe_attrs() : default value" << std::endl;
16315                throw std::runtime_error("pd_test_ndframe_attrs failed: default value");
16316            }
16317
16318            // Test keys
16319            auto keys = attrs.keys();
16320            passed = keys.size() == 3;
16321            if (!passed) {
16322                std::cout << "  [FAIL] : in pd_test_ndframe_attrs() : keys()" << std::endl;
16323                throw std::runtime_error("pd_test_ndframe_attrs failed: keys()");
16324            }
16325
16326            // Test remove
16327            passed = attrs.remove("count") && !attrs.contains("count");
16328            if (!passed) {
16329                std::cout << "  [FAIL] : in pd_test_ndframe_attrs() : remove" << std::endl;
keys (pd_test_1_all.cpp:16319)
16309            }
16310
16311            // Test default value
16312            passed = attrs.get<int>("missing", 99) == 99;
16313            if (!passed) {
16314                std::cout << "  [FAIL] : in pd_test_ndframe_attrs() : default value" << std::endl;
16315                throw std::runtime_error("pd_test_ndframe_attrs failed: default value");
16316            }
16317
16318            // Test keys
16319            auto keys = attrs.keys();
16320            passed = keys.size() == 3;
16321            if (!passed) {
16322                std::cout << "  [FAIL] : in pd_test_ndframe_attrs() : keys()" << std::endl;
16323                throw std::runtime_error("pd_test_ndframe_attrs failed: keys()");
16324            }
16325
16326            // Test remove
16327            passed = attrs.remove("count") && !attrs.contains("count");
16328            if (!passed) {
16329                std::cout << "  [FAIL] : in pd_test_ndframe_attrs() : remove" << std::endl;
keys_pandas (pd_test_3_all.cpp:19568)
19558        HighFive::Group df_grp2 = store.create_group("dataframe2");
19559        std::vector<double> col2{3.0, 4.0};
19560        df_grp2.createDataSet("column_b", col2);
19561
19562        // Write raw dataset (not a pandas object)
19563        std::vector<int> raw{1, 2, 3};
19564        store.write_dataset("raw_data", raw);
19565
19566        // Test keys with "pandas" filter - should find groups with data
19567        auto pandas_keys = store.keys_pandas("pandas");
19568        if (pandas_keys.size() < 2) {
19569            throw std::runtime_error("keys_pandas('pandas') should find at least 2 DataFrame groups");
19570        }
19571
19572        // Test keys with "native" filter - should find everything
19573        auto native_keys = store.keys_pandas("native");
19574        if (native_keys.size() < 3) {
19575            throw std::runtime_error("keys_pandas('native') should find at least 3 objects");
19576        }
19577    }
is_open (pd_test_2_all.cpp:4092)
4082            }
4083            if (writer.datetime_format() != "YYYY-MM-DD HH:MM:SS.fff") {
4084                std::cout << "  [FAIL] : datetime_format property incorrect" << std::endl;
4085                throw std::runtime_error("datetime_format property incorrect");
4086            }
4087            if (writer.if_sheet_exists() != "replace") {
4088                std::cout << "  [FAIL] : if_sheet_exists property incorrect" << std::endl;
4089                throw std::runtime_error("if_sheet_exists property incorrect");
4090            }
4091
4092            if (!writer.is_open()) {
4093                std::cout << "  [FAIL] : is_open should be true" << std::endl;
4094                throw std::runtime_error("is_open should be true");
4095            }
4096
4097            writer.close();
4098
4099            if (writer.is_open()) {
4100                std::cout << "  [FAIL] : is_open should be false after close" << std::endl;
4101                throw std::runtime_error("is_open should be false after close");
4102            }
close (pd_test_2_all.cpp:3486)
3476            // Check ZIP signature (PK..)
3477            file.seekg(0, std::ios::beg);
3478            char sig[4];
3479            file.read(sig, 4);
3480            if (sig[0] != 'P' || sig[1] != 'K' || sig[2] != 0x03 || sig[3] != 0x04) {
3481                std::cout << "  [FAIL] : in pd_test_excel_basic() : Invalid ZIP signature" << std::endl;
3482                throw std::runtime_error("pd_test_excel_basic failed: invalid ZIP signature");
3483            }
3484
3485            file.close();
3486            std::cout << " -> tests passed" << std::endl;
3487        }
3488
3489        // Test Excel export with custom sheet name
3490        void pd_test_excel_sheet_name() {
3491            std::cout << "========= Excel export with sheet name =============";
3492
3493            std::map<std::string, std::vector<double>> data = {
3494                {"X", {1.1, 2.2, 3.3}},
3495                {"Y", {4.4, 5.5, 6.6}}
contains (pd_test_1_all.cpp:2200)
2190// Test: contains method
2191// ============================================================================
2192void test_contains() {
2193    std::cout << "========= IntervalArray: contains ======================= ";
2194
2195    std::vector<numpy::float64> breaks = {0.0, 1.0, 2.0, 3.0};
2196
2197    // Right-closed intervals: (0, 1], (1, 2], (2, 3]
2198    auto arr_right = pandas::IntervalArrayFloat64::from_breaks(breaks, pandas::IntervalClosed::Right);
2199
2200    // Test contains(1.0) - should be in interval 0 but not 1 (since 1 is exclusive on left of interval 1)
2201    auto contains_1 = arr_right.contains(1.0);
2202    // (0, 1] contains 1: yes, (1, 2] contains 1: no (open on left), (2, 3] contains 1: no
2203    if (contains_1[0].value_or(false) != true ||
2204        contains_1[1].value_or(true) != false ||
2205        contains_1[2].value_or(true) != false) {
2206        std::cout << "[FAIL] : in test_contains() : right-closed contains 1.0" << std::endl;
2207        return;
2208    }
2209
2210    // Left-closed intervals: [0, 1), [1, 2), [2, 3)
exists (pd_test_1_all.cpp:13934)
13924            // Check B: should be [40, 5, 60]
13925            const auto& b_col = result["B"];
13926            if (!approx_equal(std::stod(b_col.get_value_str(0)), 40.0) ||
13927                !approx_equal(std::stod(b_col.get_value_str(1)), 5.0) ||
13928                !approx_equal(std::stod(b_col.get_value_str(2)), 60.0)) {
13929                passed = false;
13930                std::cout << "  [FAIL] : in pd_test_joining_combine_first() : column B wrong" << std::endl;
13931                throw std::runtime_error("pd_test_joining_combine_first failed: col B");
13932            }
13933
13934            // Check C exists (from right only)
13935            if (!result.has_column("C")) {
13936                passed = false;
13937                std::cout << "  [FAIL] : in pd_test_joining_combine_first() : missing column C" << std::endl;
13938                throw std::runtime_error("pd_test_joining_combine_first failed: col C missing");
13939            }
13940
13941            std::cout << " -> tests passed" << std::endl;
13942        }
13943
13944        // =====================================================================
file (pd_test_2_all.cpp:3463)
3453                {"C", {100, 200, 300, 400, 500}}
3454            };
3455
3456            pandas::DataFrame df(data);
3457
3458            // Export to Excel
3459            std::string filepath = "temp/pd_test_excel_basic.xlsx";
3460            df.to_excel(filepath);
3461
3462            // Verify file was created
3463            std::ifstream file(filepath, std::ios::binary);
3464            if (!file.good()) {
3465                std::cout << "  [FAIL] : in pd_test_excel_basic() : File was not created" << std::endl;
3466                throw std::runtime_error("pd_test_excel_basic failed: file not created");
3467            }
3468
3469            // Check file size is reasonable (valid XLSX should be > 1KB)
3470            file.seekg(0, std::ios::end);
3471            auto size = file.tellg();
3472            if (size < 1000) {
3473                std::cout << "  [FAIL] : in pd_test_excel_basic() : File size too small: " << size << std::endl;
file (pd_test_2_all.cpp:3463)
3453                {"C", {100, 200, 300, 400, 500}}
3454            };
3455
3456            pandas::DataFrame df(data);
3457
3458            // Export to Excel
3459            std::string filepath = "temp/pd_test_excel_basic.xlsx";
3460            df.to_excel(filepath);
3461
3462            // Verify file was created
3463            std::ifstream file(filepath, std::ios::binary);
3464            if (!file.good()) {
3465                std::cout << "  [FAIL] : in pd_test_excel_basic() : File was not created" << std::endl;
3466                throw std::runtime_error("pd_test_excel_basic failed: file not created");
3467            }
3468
3469            // Check file size is reasonable (valid XLSX should be > 1KB)
3470            file.seekg(0, std::ios::end);
3471            auto size = file.tellg();
3472            if (size < 1000) {
3473                std::cout << "  [FAIL] : in pd_test_excel_basic() : File size too small: " << size << std::endl;
filename (pd_test_3_all.cpp:19497)
19487    {
19488        pandas::HDF5Store store(path, "w");
19489
19490        // Test is_open
19491        if (!store.is_open()) {
19492            throw std::runtime_error("Store should be open initially");
19493        }
19494
19495        // Test filename
19496        if (store.filename() != path) {
19497            throw std::runtime_error("filename() should return path");
19498        }
19499
19500        // Test close
19501        store.close();
19502
19503        if (store.is_open()) {
19504            throw std::runtime_error("Store should be closed after close()");
19505        }
19506    }
groups (pd_test_2_all.cpp:20864)
20854// =====================================================================
20855// Per-group expanding tests
20856// =====================================================================
20857
20858void test_series_groupby_expanding_sum() {
20859    std::cout << "  -- test_series_groupby_expanding_sum --" << std::endl;
20860
20861    // Two groups: A=[1,2,3], B=[10,20]
20862    std::vector<numpy::float64> vals = {1.0, 10.0, 2.0, 20.0, 3.0};
20863    pandas::Series<numpy::float64> data(vals);
20864    pandas::Series<std::string> groups({"A", "B", "A", "B", "A"});
20865
20866    auto sgb = data.groupby(groups);
20867    pandas::SeriesGroupByExpandingWindow ew(sgb, 1);
20868    auto result = ew.sum();
20869
20870    check(result.size() == 5, "size_5");
20871    // A group: expanding sum = 1, 3, 6
20872    // B group: expanding sum = 10, 30
20873    // Original order: [A:1, B:10, A:3, B:30, A:6]
20874    check(approx_eq(result[0], 1.0), "A_exp_sum_0");
has_attribute (pd_test_3_all.cpp:19325)
19315    {
19316        pandas::HDF5Store store(path, "r");
19317        auto desc = store.read_attribute("data", "description");
19318        if (desc != "Test dataset")
19319            throw std::runtime_error("test_attributes: description mismatch");
19320
19321        auto ver = store.read_attribute_as<int>("data", "version");
19322        if (ver != 1)
19323            throw std::runtime_error("test_attributes: version mismatch");
19324
19325        if (!store.has_attribute("data", "description"))
19326            throw std::runtime_error("test_attributes: has_attribute failed");
19327    }
19328
19329    std::remove(path.c_str());
19330    std::cout << "  test_attributes passed\n";
19331}
19332
19333void test_integer_types() {
19334    std::string path = "test_hdf5_int.h5";
info (pd_test_1_all.cpp:7122)
7112            }
7113            if (!empty_params_error) {
7114                std::cout << "  [FAIL] : select_dtypes empty params should throw" << std::endl;
7115                throw std::runtime_error("pd_test_dataframe_select_dtypes failed: empty params error");
7116            }
7117
7118            std::cout << " -> tests passed" << std::endl;
7119        }
7120
7121        // =====================================================================
7122        // Test: info() method
7123        // =====================================================================
7124        void pd_test_dataframe_info() {
7125            std::cout << "========= info ========================";
7126
7127            // Test basic info() with stringstream
7128            std::map<std::string, std::vector<int>> data = {
7129                {"A", {1, 2, 3, 4, 5}},
7130                {"B", {10, 20, 30, 40, 50}},
7131                {"C", {100, 200, 300, 400, 500}}
7132            };
path (pd_test_2_all.cpp:4071)
4061            std::cout << " -> tests passed" << std::endl;
4062        }
4063
4064        void pd_test_excel_writer_properties() {
4065            std::cout << "========= ExcelWriter properties ===================";
4066
4067            pandas::ExcelWriter writer("temp/test_writer_props.xlsx", "xlsxwriter",
4068                "YYYY/MM/DD", "YYYY-MM-DD HH:MM:SS.fff", "w", std::nullopt, "replace");
4069
4070            if (writer.path() != "temp/test_writer_props.xlsx") {
4071                std::cout << "  [FAIL] : path property incorrect" << std::endl;
4072                throw std::runtime_error("path property incorrect");
4073            }
4074            if (writer.engine() != "xlsxwriter") {
4075                std::cout << "  [FAIL] : engine property incorrect: " << writer.engine() << std::endl;
4076                throw std::runtime_error("engine property incorrect");
4077            }
4078            if (writer.date_format() != "YYYY/MM/DD") {
4079                std::cout << "  [FAIL] : date_format property incorrect" << std::endl;
4080                throw std::runtime_error("date_format property incorrect");
read_attribute (pd_test_3_all.cpp:19317)
19307    {
19308        pandas::HDF5Store store(path, "w");
19309        store.write_dataset("data", std::vector<int>{1, 2, 3});
19310        store.write_attribute("data", "description", "Test dataset");
19311        store.write_attribute("data", "version", 1);
19312    }
19313
19314    {
19315        pandas::HDF5Store store(path, "r");
19316        auto desc = store.read_attribute("data", "description");
19317        if (desc != "Test dataset")
19318            throw std::runtime_error("test_attributes: description mismatch");
19319
19320        auto ver = store.read_attribute_as<int>("data", "version");
19321        if (ver != 1)
19322            throw std::runtime_error("test_attributes: version mismatch");
19323
19324        if (!store.has_attribute("data", "description"))
19325            throw std::runtime_error("test_attributes: has_attribute failed");
19326    }
read_attribute_as (pd_test_3_all.cpp:19321)
19311        store.write_attribute("data", "description", "Test dataset");
19312        store.write_attribute("data", "version", 1);
19313    }
19314
19315    {
19316        pandas::HDF5Store store(path, "r");
19317        auto desc = store.read_attribute("data", "description");
19318        if (desc != "Test dataset")
19319            throw std::runtime_error("test_attributes: description mismatch");
19320
19321        auto ver = store.read_attribute_as<int>("data", "version");
19322        if (ver != 1)
19323            throw std::runtime_error("test_attributes: version mismatch");
19324
19325        if (!store.has_attribute("data", "description"))
19326            throw std::runtime_error("test_attributes: has_attribute failed");
19327    }
19328
19329    std::remove(path.c_str());
19330    std::cout << "  test_attributes passed\n";
19331}
read_dataset_2d (pd_test_3_all.cpp:19260)
19250        std::vector<std::vector<double>> data = {
19251            {1.0, 2.0, 3.0},
19252            {4.0, 5.0, 6.0}
19253        };
19254        store.write_dataset_2d("matrix", data);
19255    }
19256
19257    // Read
19258    {
19259        pandas::HDF5Store store(path, "r");
19260        auto result = store.read_dataset_2d<double>("matrix");
19261        if (result.size() != 2)
19262            throw std::runtime_error("test_write_read_2d: row count mismatch");
19263        if (result[0].size() != 3)
19264            throw std::runtime_error("test_write_read_2d: col count mismatch");
19265        if (std::abs(result[1][2] - 6.0) > 1e-10)
19266            throw std::runtime_error("test_write_read_2d: value mismatch");
19267    }
19268
19269    std::remove(path.c_str());
19270    std::cout << "  test_write_read_2d passed\n";
remove (pd_test_1_all.cpp:16327)
16317            // Test keys
16318            auto keys = attrs.keys();
16319            passed = keys.size() == 3;
16320            if (!passed) {
16321                std::cout << "  [FAIL] : in pd_test_ndframe_attrs() : keys()" << std::endl;
16322                throw std::runtime_error("pd_test_ndframe_attrs failed: keys()");
16323            }
16324
16325            // Test remove
16326            passed = attrs.remove("count") && !attrs.contains("count");
16327            if (!passed) {
16328                std::cout << "  [FAIL] : in pd_test_ndframe_attrs() : remove" << std::endl;
16329                throw std::runtime_error("pd_test_ndframe_attrs failed: remove");
16330            }
16331
16332            // Test has_type
16333            passed = attrs.has_type<std::string>("author") && !attrs.has_type<int>("author");
16334            if (!passed) {
16335                std::cout << "  [FAIL] : in pd_test_ndframe_attrs() : has_type" << std::endl;
16336                throw std::runtime_error("pd_test_ndframe_attrs failed: has_type");
remove_pandas (pd_test_3_all.cpp:19600)
19590        HighFive::Group hdf_grp = store.create_group("to_remove");
19591        std::vector<double> data{1.0, 2.0};
19592        hdf_grp.createDataSet("col", data);
19593
19594        // Verify it exists
19595        if (!store.contains("to_remove")) {
19596            throw std::runtime_error("Group should exist before remove");
19597        }
19598
19599        // Remove it
19600        store.remove_pandas("to_remove");
19601
19602        // Verify it's gone
19603        if (store.contains("to_remove")) {
19604            throw std::runtime_error("Group should not exist after remove");
19605        }
19606
19607        // Remove nonexistent (should not throw)
19608        store.remove_pandas("does_not_exist");
19609    }
19610    std::cout << "passed\n";
size (pd_test_1_all.cpp:22)
12#include "../pandas/pd_boolean_array.h"
13
14namespace dataframe_tests {
15
16namespace dataframe_tests_boolean_array {
17    void pd_test_boolean_array_constructors() {
18        std::cout << "========= BooleanArray: constructors ======================= ";
19
20        // Default constructor
21        pandas::BooleanArray arr1;
22        if (arr1.size() != 0) {
23            std::cout << "  [FAIL] : in pd_test_boolean_array_constructors() : default constructor size != 0" << std::endl;
24            throw std::runtime_error("pd_test_boolean_array_constructors failed: default constructor size != 0");
25        }
26
27        // Initializer list constructor
28        pandas::BooleanArray arr2({
29            std::optional<bool>(true),
30            std::optional<bool>(false),
31            std::nullopt,
32            std::optional<bool>(true)
test (pd_test_3_all.cpp:18161)
18151    try { pd_test_combine_requires_func(); } catch (...) { failures++; }
18152    // Phase 23: Export methods verification
18153    try { pd_test_to_html_params(); } catch (...) { failures++; }
18154    try { pd_test_to_excel_params(); } catch (...) { failures++; }
18155    try { pd_test_to_feather_params(); } catch (...) { failures++; }
18156    try { pd_test_to_hdf_params(); } catch (...) { failures++; }
18157    try { pd_test_to_stata_params(); } catch (...) { failures++; }
18158    try { pd_test_to_gbq_throws(); } catch (...) { failures++; }
18159
18160    if (failures > 0) {
18161        std::cout << "\n*** " << failures << " test(s) failed ***\n";
18162    }
18163
18164    return failures;
18165}
18166
18167} // namespace dataframe_tests_io_params
18168
18169// Main entry point for pd_test_all.cpp
18170int pd_test_dataframe_io_params_main() {
18171    std::cout << "====================================== running pd_test_dataframe_io_params ====================================== " << std::endl;
walk (pd_test_3_all.cpp:19683)
19673    {
19674        pandas::HDF5Store store(path, "w");
19675
19676        // Create structure
19677        HighFive::Group hdf_grp = store.create_group("folder");
19678        std::vector<double> data{1.0, 2.0};
19679        store.write_dataset("root_data", data);
19680        hdf_grp.createDataSet("nested_data", data);
19681
19682        // Walk from root
19683        auto result = store.walk("/");
19684
19685        if (result.empty()) {
19686            throw std::runtime_error("walk() should return at least one entry");
19687        }
19688
19689        // First entry should be root
19690        auto& [path_str, subgroups, leaves] = result[0];
19691        if (path_str != "/") {
19692            throw std::runtime_error("First entry should be root '/'");
19693        }
write_attribute (pd_test_3_all.cpp:19311)
19301    std::remove(path.c_str());
19302    std::cout << "  test_groups passed\n";
19303}
19304
19305void test_attributes() {
19306    std::string path = "test_hdf5_attr.h5";
19307
19308    {
19309        pandas::HDF5Store store(path, "w");
19310        store.write_dataset("data", std::vector<int>{1, 2, 3});
19311        store.write_attribute("data", "description", "Test dataset");
19312        store.write_attribute("data", "version", 1);
19313    }
19314
19315    {
19316        pandas::HDF5Store store(path, "r");
19317        auto desc = store.read_attribute("data", "description");
19318        if (desc != "Test dataset")
19319            throw std::runtime_error("test_attributes: description mismatch");
19320
19321        auto ver = store.read_attribute_as<int>("data", "version");
write_attribute (pd_test_3_all.cpp:19311)
19301    std::remove(path.c_str());
19302    std::cout << "  test_groups passed\n";
19303}
19304
19305void test_attributes() {
19306    std::string path = "test_hdf5_attr.h5";
19307
19308    {
19309        pandas::HDF5Store store(path, "w");
19310        store.write_dataset("data", std::vector<int>{1, 2, 3});
19311        store.write_attribute("data", "description", "Test dataset");
19312        store.write_attribute("data", "version", 1);
19313    }
19314
19315    {
19316        pandas::HDF5Store store(path, "r");
19317        auto desc = store.read_attribute("data", "description");
19318        if (desc != "Test dataset")
19319            throw std::runtime_error("test_attributes: description mismatch");
19320
19321        auto ver = store.read_attribute_as<int>("data", "version");
write_dataset (pd_test_3_all.cpp:19225)
19215namespace dataframe_tests {
19216namespace dataframe_tests_hdf5_real {
19217
19218void test_write_read_1d() {
19219    std::string path = "test_hdf5_real.h5";
19220
19221    // Write
19222    {
19223        pandas::HDF5Store store(path, "w");
19224        std::vector<double> data = {1.0, 2.0, 3.0, 4.0, 5.0};
19225        store.write_dataset("my_data", data);
19226    }
19227
19228    // Read
19229    {
19230        pandas::HDF5Store store(path, "r");
19231        auto result = store.read_dataset<double>("my_data");
19232        if (result.size() != 5)
19233            throw std::runtime_error("test_write_read_1d: size mismatch");
19234        if (std::abs(result[0] - 1.0) > 1e-10)
19235            throw std::runtime_error("test_write_read_1d: value mismatch at [0]");
write_dataset_2d (pd_test_3_all.cpp:19254)
19244void test_write_read_2d() {
19245    std::string path = "test_hdf5_2d.h5";
19246
19247    // Write
19248    {
19249        pandas::HDF5Store store(path, "w");
19250        std::vector<std::vector<double>> data = {
19251            {1.0, 2.0, 3.0},
19252            {4.0, 5.0, 6.0}
19253        };
19254        store.write_dataset_2d("matrix", data);
19255    }
19256
19257    // Read
19258    {
19259        pandas::HDF5Store store(path, "r");
19260        auto result = store.read_dataset_2d<double>("matrix");
19261        if (result.size() != 2)
19262            throw std::runtime_error("test_write_read_2d: row count mismatch");
19263        if (result[0].size() != 3)
19264            throw std::runtime_error("test_write_read_2d: col count mismatch");