ICallable#

class pandas::ICallable#

pandas C++ class.

Example#

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

// Use ICallable
ICallable obj;
// ... operations ...

Other Methods#

Signature

Return Type

Location

Example

virtual ApplyCellResult invoke_cell(const MapCellInput&) const = 0

virtual ApplyCellResult

pd_callable_handle.h:62

View

virtual ApplyCellResult invoke_col(const ApplyColInput&) const

virtual ApplyCellResult

pd_callable_handle.h:73

virtual ApplyCellResult invoke_row(const ApplyRowInput&) const

virtual ApplyCellResult

pd_callable_handle.h:68

virtual DataFrame invoke_with_dataframe(const DataFrame&) const

virtual DataFrame

pd_callable_handle.h:84

View

virtual std::string repr() const = 0

virtual std::string

pd_callable_handle.h:57

View

throw_invoke_unsupported("invoke_row")

pd_callable_handle.h:69

throw_invoke_unsupported("invoke_col")

pd_callable_handle.h:74

Code Examples#

The following examples are extracted from the test suite.

invoke_cell (pd_test_5_all.cpp:91860)
91850}
91851
91852// --- f_test_24_dataframe_where_core_9.cpp ---
91853
91854namespace f_test_24_dataframe_where_core_9_ns {
91855
91856class IdentityCallable : public pandas::ICallable {
91857public:
91858    std::string repr() const override { return "IdentityCallable"; }
91859
91860    pandas::ApplyCellResult invoke_cell(const pandas::MapCellInput&) const override {
91861        // Not used in where_resolved path; throw to make accidental use loud.
91862        throw pandas::ValueError("IdentityCallable: invoke_cell unsupported");
91863    }
91864
91865    // The where dispatcher calls this entry — proof-test signature mirrors
91866    // plan C-24.2 Change C-24.2 ("cond.callable_ptr->invoke_with_dataframe(*this)").
91867    pandas::DataFrame invoke_with_dataframe(const pandas::DataFrame& df) const override {
91868        return df;
91869    }
91870};
invoke_with_dataframe (pd_test_5_all.cpp:91866)
91856class IdentityCallable : public pandas::ICallable {
91857public:
91858    std::string repr() const override { return "IdentityCallable"; }
91859
91860    pandas::ApplyCellResult invoke_cell(const pandas::MapCellInput&) const override {
91861        // Not used in where_resolved path; throw to make accidental use loud.
91862        throw pandas::ValueError("IdentityCallable: invoke_cell unsupported");
91863    }
91864
91865    // The where dispatcher calls this entry — proof-test signature mirrors
91866    // plan C-24.2 Change C-24.2 ("cond.callable_ptr->invoke_with_dataframe(*this)").
91867    pandas::DataFrame invoke_with_dataframe(const pandas::DataFrame& df) const override {
91868        return df;
91869    }
91870};
91871
91872class AllTrueCallable : public pandas::ICallable {
91873public:
91874    std::string repr() const override { return "AllTrueCallable"; }
91875
91876    pandas::ApplyCellResult invoke_cell(const pandas::MapCellInput&) const override {
repr (pd_test_1_all.cpp:10906)
10896    std::cout << " -> tests passed" << std::endl;
10897}
10898
10899void pd_test_extension_index_repr() {
10900    std::cout << "========= repr =========================";
10901
10902    pandas::CategoricalArray arr({"a", "b", "c"});
10903    // Use ExtensionIndex<CategoricalArray> directly to test base class repr
10904    pandas::ExtensionIndex<pandas::CategoricalArray> idx(arr, "test");
10905
10906    std::string repr_str = idx.repr();
10907
10908    bool passed = (!repr_str.empty() && repr_str.find("ExtensionIndex") != std::string::npos);
10909    if (!passed) {
10910        std::cout << "  [FAIL] : in pd_test_extension_index_repr() : repr check failed" << std::endl;
10911        throw std::runtime_error("pd_test_extension_index_repr failed");
10912    }
10913
10914    std::cout << " -> tests passed" << std::endl;
10915}