StyleSubset =========== .. cpp:class:: pandas::StyleSubset Styling class for DataFrame rendering. Example ------- .. code-block:: cpp #include using namespace pandas; // Use StyleSubset StyleSubset obj; // ... operations ... Constructors ------------ .. list-table:: :widths: 55 25 20 :header-rows: 1 * - Signature - Location - Example * - ``StyleSubset() = default`` - pd_styler.h:48 - * - ``StyleSubset(const std::vector& cols, const std::vector& r)`` - pd_styler.h:51 - Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``StyleSubset(const std::vector& cols) : columns(cols)`` - StyleSubset(const std::vector& cols) : - pd_styler.h:49 - :ref:`View ` * - ``StyleSubset(const std::vector& r) : rows(r)`` - StyleSubset(const std::vector& r) : - pd_styler.h:50 - :ref:`View ` Code Examples ------------- The following examples are extracted from the test suite. .. _example-stylesubset-columns-0: .. dropdown:: columns (pd_test_1_all.cpp:6220) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 6210 :emphasize-lines: 11 throw std::runtime_error("pd_test_dataframe_properties failed: should be empty"); } // Test nbytes > 0 for non-empty if (df.nbytes() == 0) { std::cout << " [FAIL] : in pd_test_dataframe_properties() : nbytes should be > 0" << std::endl; throw std::runtime_error("pd_test_dataframe_properties failed: nbytes should be > 0"); } // Test columns index if (df.columns().size() != 3) { std::cout << " [FAIL] : in pd_test_dataframe_properties() : columns size != 3" << std::endl; throw std::runtime_error("pd_test_dataframe_properties failed: columns size != 3"); } // Test dtypes auto dtypes = df.dtypes(); if (dtypes.size() != 3) { std::cout << " [FAIL] : in pd_test_dataframe_properties() : dtypes size != 3" << std::endl; throw std::runtime_error("pd_test_dataframe_properties failed: dtypes size != 3"); } .. _example-stylesubset-rows-1: .. dropdown:: rows (pd_test_1_all.cpp:6893) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 6883 :emphasize-lines: 11 } // Test stack { std::map> data; data["A"] = {1, 2}; data["B"] = {3, 4}; pandas::DataFrame df(data); auto stacked = df.stack(); // Stack should produce 4 rows (2 rows * 2 columns) if (stacked.nrows() != 4) { std::cout << " [FAIL] : in pd_test_dataframe_reshape() : stack nrows != 4, got " << stacked.nrows() << std::endl; throw std::runtime_error("pd_test_dataframe_reshape failed: stack nrows"); } } std::cout << " -> tests passed" << std::endl; } // =====================================================================