StringLookupResult ================== .. cpp:class:: pandas::StringLookupResult pandas C++ class. Example ------- .. code-block:: cpp #include using namespace pandas; // Use StringLookupResult StringLookupResult obj; // ... operations ... Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``static StringLookupResult miss()`` - static StringLookupResult - pd_index_lookup.h:96 - :ref:`View ` * - ``static StringLookupResult ranged(std::size_t lo, std::size_t hi)`` - static StringLookupResult - pd_index_lookup.h:88 - * - ``static StringLookupResult scalar(std::size_t idx)`` - static StringLookupResult - pd_index_lookup.h:80 - :ref:`View ` Code Examples ------------- The following examples are extracted from the test suite. .. _example-stringlookupresult-miss-0: .. dropdown:: miss (pd_test_5_all.cpp:83706) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 83696 :emphasize-lines: 11 catch (const pandas::KeyError&) { ok_typed = true; } catch (const std::out_of_range&) { ok_std = true; } catch (const std::exception&) { ok_std = true; } pandas_tests::check(ok_typed || ok_std, "case_20.idx_get_loc_nan_missing.throws_some_keyerror", local_fail); } // Series built over a NaN-bearing index then get_loc(NaN) // probe via the underlying Index — exercises NaN equality path on // a label miss (separate from the integer index case above). { bool ok_typed = false; bool ok_std = false; try { const double nan_v = std::numeric_limits::quiet_NaN(); pandas::Index idx({nan_v, 10.0, 20.0}); // Looking up a value that's not in the index where one // entry is NaN — must still resolve to KeyError post-90a. (void)idx.get_loc(999.0); } .. _example-stringlookupresult-scalar-1: .. dropdown:: scalar (pd_test_2_all.cpp:20114) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 20104 :emphasize-lines: 11 check(approx(result["A"].get_value_double(2), 3.0), "where_df_A2"); check(approx(result["A"].get_value_double(3), 4.0), "where_df_A3"); // B: cond all true -> all kept check(approx(result["B"].get_value_double(0), 5.0), "where_df_B0"); check(approx(result["B"].get_value_double(1), 6.0), "where_df_B1"); check(approx(result["B"].get_value_double(2), 7.0), "where_df_B2"); check(approx(result["B"].get_value_double(3), 8.0), "where_df_B3"); } // Test where with scalar (verify existing path still works) void pd_test_fillna_where_where_scalar() { std::cout << " -- pd_test_fillna_where_where_scalar --" << std::endl; auto df = make_df("A", {1.0, 2.0, 3.0}, "B", {4.0, 5.0, 6.0}); auto cond = make_df("A", {1.0, 0.0, 1.0}, "B", {0.0, 1.0, 0.0}); pandas::DataFrame result = df.where(cond, -99.0); check(approx(result["A"].get_value_double(0), 1.0), "where_scalar_A0"); check(approx(result["A"].get_value_double(1), -99.0), "where_scalar_A1");