StyleSubset#

class pandas::StyleSubset#

Styling class for DataFrame rendering.

Example#

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

// Use StyleSubset
StyleSubset obj;
// ... operations ...

Constructors#

Signature

Location

Example

StyleSubset() = default

pd_styler.h:48

StyleSubset(const std::vector<std::string>& cols, const std::vector<size_t>& r)

pd_styler.h:51

Other Methods#

Signature

Return Type

Location

Example

StyleSubset(const std::vector<std::string>& cols) : columns(cols)

StyleSubset(const std::vector<std::string>& cols) :

pd_styler.h:49

View

StyleSubset(const std::vector<size_t>& r) : rows(r)

StyleSubset(const std::vector<size_t>& r) :

pd_styler.h:50

View

Code Examples#

The following examples are extracted from the test suite.

columns (pd_test_1_all.cpp:6220)
6210                throw std::runtime_error("pd_test_dataframe_properties failed: should be empty");
6211            }
6212
6213            // Test nbytes > 0 for non-empty
6214            if (df.nbytes() == 0) {
6215                std::cout << "  [FAIL] : in pd_test_dataframe_properties() : nbytes should be > 0" << std::endl;
6216                throw std::runtime_error("pd_test_dataframe_properties failed: nbytes should be > 0");
6217            }
6218
6219            // Test columns index
6220            if (df.columns().size() != 3) {
6221                std::cout << "  [FAIL] : in pd_test_dataframe_properties() : columns size != 3" << std::endl;
6222                throw std::runtime_error("pd_test_dataframe_properties failed: columns size != 3");
6223            }
6224
6225            // Test dtypes
6226            auto dtypes = df.dtypes();
6227            if (dtypes.size() != 3) {
6228                std::cout << "  [FAIL] : in pd_test_dataframe_properties() : dtypes size != 3" << std::endl;
6229                throw std::runtime_error("pd_test_dataframe_properties failed: dtypes size != 3");
6230            }
rows (pd_test_1_all.cpp:6893)
6883            }
6884
6885            // Test stack
6886            {
6887                std::map<std::string, std::vector<int>> data;
6888                data["A"] = {1, 2};
6889                data["B"] = {3, 4};
6890                pandas::DataFrame df(data);
6891
6892                auto stacked = df.stack();
6893                // Stack should produce 4 rows (2 rows * 2 columns)
6894                if (stacked.nrows() != 4) {
6895                    std::cout << "  [FAIL] : in pd_test_dataframe_reshape() : stack nrows != 4, got " << stacked.nrows() << std::endl;
6896                    throw std::runtime_error("pd_test_dataframe_reshape failed: stack nrows");
6897                }
6898            }
6899
6900            std::cout << " -> tests passed" << std::endl;
6901        }
6902
6903        // =====================================================================