StringLookupResult#

class pandas::StringLookupResult#

pandas C++ class.

Example#

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

// Use StringLookupResult
StringLookupResult obj;
// ... operations ...

Other Methods#

Signature

Return Type

Location

Example

static StringLookupResult miss()

static StringLookupResult

pd_index_lookup.h:96

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

View

Code Examples#

The following examples are extracted from the test suite.

miss (pd_test_5_all.cpp:83706)
83696        catch (const pandas::KeyError&)   { ok_typed = true; }
83697        catch (const std::out_of_range&)  { ok_std   = true; }
83698        catch (const std::exception&)     { ok_std   = true; }
83699        pandas_tests::check(ok_typed || ok_std,
83700            "case_20.idx_get_loc_nan_missing.throws_some_keyerror",
83701            local_fail);
83702    }
83703
83704    // Series<double> built over a NaN-bearing index then get_loc(NaN)
83705    // probe via the underlying Index — exercises NaN equality path on
83706    // a label miss (separate from the integer index case above).
83707    {
83708        bool ok_typed = false;
83709        bool ok_std   = false;
83710        try {
83711            const double nan_v = std::numeric_limits<double>::quiet_NaN();
83712            pandas::Index<double> idx({nan_v, 10.0, 20.0});
83713            // Looking up a value that's not in the index where one
83714            // entry is NaN — must still resolve to KeyError post-90a.
83715            (void)idx.get_loc(999.0);
83716        }
scalar (pd_test_2_all.cpp:20114)
20104    check(approx(result["A"].get_value_double(2), 3.0), "where_df_A2");
20105    check(approx(result["A"].get_value_double(3), 4.0), "where_df_A3");
20106
20107    // B: cond all true -> all kept
20108    check(approx(result["B"].get_value_double(0), 5.0), "where_df_B0");
20109    check(approx(result["B"].get_value_double(1), 6.0), "where_df_B1");
20110    check(approx(result["B"].get_value_double(2), 7.0), "where_df_B2");
20111    check(approx(result["B"].get_value_double(3), 8.0), "where_df_B3");
20112}
20113
20114// Test where with scalar (verify existing path still works)
20115void pd_test_fillna_where_where_scalar() {
20116    std::cout << "  -- pd_test_fillna_where_where_scalar --" << std::endl;
20117
20118    auto df = make_df("A", {1.0, 2.0, 3.0}, "B", {4.0, 5.0, 6.0});
20119    auto cond = make_df("A", {1.0, 0.0, 1.0}, "B", {0.0, 1.0, 0.0});
20120
20121    pandas::DataFrame result = df.where(cond, -99.0);
20122
20123    check(approx(result["A"].get_value_double(0), 1.0), "where_scalar_A0");
20124    check(approx(result["A"].get_value_double(1), -99.0), "where_scalar_A1");