DataFrameGroupByColumn ====================== .. cpp:class:: pandas::DataFrameGroupByColumn pandas C++ class. Example ------- .. code-block:: cpp #include using namespace pandas; // Use DataFrameGroupByColumn DataFrameGroupByColumn obj; // ... operations ... Aggregation ----------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``std::vector transform(std::function(const std::vector&)> fn) const`` - std::vector - pd_groupby.h:704 - :ref:`View ` Code Examples ------------- The following examples are extracted from the test suite. .. _example-dataframegroupbycolumn-transform-0: .. dropdown:: transform (pd_test_1_all.cpp:11071) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 11061 :emphasize-lines: 11 std::cout << " -> tests passed" << std::endl; } void pd_test_func_apply_series_transform() { std::cout << "========= Series transform ============================"; pandas::Series s({1.0, 2.0, 3.0, 4.0}, "values"); // Transform must return same shape auto result = s.transform([](double x) { return x * 2 + 1; }); bool passed = true; if (result.size() != s.size()) { passed = false; std::cout << " [FAIL] : in pd_test_func_apply_series_transform() : size changed" << std::endl; throw std::runtime_error("pd_test_func_apply_series_transform failed: size changed"); } std::vector expected = {3.0, 5.0, 7.0, 9.0}; for (size_t i = 0; i < result.size(); ++i) {