ICallable ========= .. cpp:class:: pandas::ICallable pandas C++ class. Example ------- .. code-block:: cpp #include using namespace pandas; // Use ICallable ICallable obj; // ... operations ... Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``virtual ApplyCellResult invoke_cell(const MapCellInput&) const = 0`` - virtual ApplyCellResult - pd_callable_handle.h:62 - :ref:`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 - :ref:`View ` * - ``virtual std::string repr() const = 0`` - virtual std::string - pd_callable_handle.h:57 - :ref:`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. .. _example-icallable-invoke_cell-0: .. dropdown:: invoke_cell (pd_test_5_all.cpp:91860) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 91850 :emphasize-lines: 11 } // --- f_test_24_dataframe_where_core_9.cpp --- namespace f_test_24_dataframe_where_core_9_ns { class IdentityCallable : public pandas::ICallable { public: std::string repr() const override { return "IdentityCallable"; } pandas::ApplyCellResult invoke_cell(const pandas::MapCellInput&) const override { // Not used in where_resolved path; throw to make accidental use loud. throw pandas::ValueError("IdentityCallable: invoke_cell unsupported"); } // The where dispatcher calls this entry — proof-test signature mirrors // plan C-24.2 Change C-24.2 ("cond.callable_ptr->invoke_with_dataframe(*this)"). pandas::DataFrame invoke_with_dataframe(const pandas::DataFrame& df) const override { return df; } }; .. _example-icallable-invoke_with_dataframe-1: .. dropdown:: invoke_with_dataframe (pd_test_5_all.cpp:91866) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 91856 :emphasize-lines: 11 class IdentityCallable : public pandas::ICallable { public: std::string repr() const override { return "IdentityCallable"; } pandas::ApplyCellResult invoke_cell(const pandas::MapCellInput&) const override { // Not used in where_resolved path; throw to make accidental use loud. throw pandas::ValueError("IdentityCallable: invoke_cell unsupported"); } // The where dispatcher calls this entry — proof-test signature mirrors // plan C-24.2 Change C-24.2 ("cond.callable_ptr->invoke_with_dataframe(*this)"). pandas::DataFrame invoke_with_dataframe(const pandas::DataFrame& df) const override { return df; } }; class AllTrueCallable : public pandas::ICallable { public: std::string repr() const override { return "AllTrueCallable"; } pandas::ApplyCellResult invoke_cell(const pandas::MapCellInput&) const override { .. _example-icallable-repr-2: .. dropdown:: repr (pd_test_1_all.cpp:10906) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 10896 :emphasize-lines: 11 std::cout << " -> tests passed" << std::endl; } void pd_test_extension_index_repr() { std::cout << "========= repr ========================="; pandas::CategoricalArray arr({"a", "b", "c"}); // Use ExtensionIndex directly to test base class repr pandas::ExtensionIndex idx(arr, "test"); std::string repr_str = idx.repr(); bool passed = (!repr_str.empty() && repr_str.find("ExtensionIndex") != std::string::npos); if (!passed) { std::cout << " [FAIL] : in pd_test_extension_index_repr() : repr check failed" << std::endl; throw std::runtime_error("pd_test_extension_index_repr failed"); } std::cout << " -> tests passed" << std::endl; }