DataFrameGroupByColumn#

class pandas::DataFrameGroupByColumn#

pandas C++ class.

Example#

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

// Use DataFrameGroupByColumn
DataFrameGroupByColumn obj;
// ... operations ...

Aggregation#

Signature

Return Type

Location

Example

std::vector<T> transform(std::function<std::vector<T>(const std::vector<T>&)> fn) const

std::vector<T>

pd_groupby.h:704

View

Code Examples#

The following examples are extracted from the test suite.

transform (pd_test_1_all.cpp:11071)
11061            std::cout << " -> tests passed" << std::endl;
11062        }
11063
11064        void pd_test_func_apply_series_transform() {
11065            std::cout << "========= Series transform ============================";
11066
11067            pandas::Series<double> s({1.0, 2.0, 3.0, 4.0}, "values");
11068
11069            // Transform must return same shape
11070            auto result = s.transform([](double x) { return x * 2 + 1; });
11071
11072            bool passed = true;
11073            if (result.size() != s.size()) {
11074                passed = false;
11075                std::cout << "  [FAIL] : in pd_test_func_apply_series_transform() : size changed" << std::endl;
11076                throw std::runtime_error("pd_test_func_apply_series_transform failed: size changed");
11077            }
11078
11079            std::vector<double> expected = {3.0, 5.0, 7.0, 9.0};
11080            for (size_t i = 0; i < result.size(); ++i) {