RowTuple#
-
class pandas::RowTuple#
Iterator class for traversing pandas data structures.
Example#
#include <pandas/pandas.h>
using namespace pandas;
// Use RowTuple
RowTuple obj;
// ... operations ...
Indexing / Selection#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
const std::string& |
pd_dataframe.h:2326 |
I/O#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
std::string |
pd_dataframe.h:2340 |
Other Methods#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
size_t |
pd_dataframe.h:2333 |
Code Examples#
The following examples are extracted from the test suite.
at (pd_test_1_all.cpp:6581)
6571 // Test isna/notna with float data
6572 {
6573 std::map<std::string, std::vector<numpy::float64>> float_data;
6574 float_data["X"] = {1.0, std::nan(""), 3.0};
6575 float_data["Y"] = {4.0, 5.0, std::nan("")};
6576 pandas::DataFrame df_na(float_data);
6577
6578 auto na_mask = df_na.isna();
6579 // Row 1, col 0 (X) should be NA
6580 if (!na_mask.getElementAt({1, 0})) {
6581 std::cout << " [FAIL] : in pd_test_dataframe_manipulation() : isna at (1,0) should be true" << std::endl;
6582 throw std::runtime_error("pd_test_dataframe_manipulation failed: isna at (1,0)");
6583 }
6584 // Row 2, col 1 (Y) should be NA
6585 if (!na_mask.getElementAt({2, 1})) {
6586 std::cout << " [FAIL] : in pd_test_dataframe_manipulation() : isna at (2,1) should be true" << std::endl;
6587 throw std::runtime_error("pd_test_dataframe_manipulation failed: isna at (2,1)");
6588 }
6589 // Row 0, col 0 should NOT be NA
6590 if (na_mask.getElementAt({0, 0})) {
6591 std::cout << " [FAIL] : in pd_test_dataframe_manipulation() : isna at (0,0) should be false" << std::endl;
to_string (pd_test_1_all.cpp:2693)
2683 pandas::PeriodArray arr_m(std::vector<std::string>{
2684 "2020-01",
2685 "NaT",
2686 "2025-06"
2687 }, "M");
2688
2689 // Year
2690 auto years = arr_m.year();
2691 auto y0 = years[0];
2692 if (!y0.has_value() || y0.value() != 2020) {
2693 std::cout << " [FAIL] : year[0] should be 2020, got " << (y0.has_value() ? std::to_string(y0.value()) : "NA") << std::endl;
2694 throw std::runtime_error("pd_test_period_array_year_month_quarter failed: year[0]");
2695 }
2696
2697 auto y1 = years[1];
2698 if (y1.has_value()) {
2699 std::cout << " [FAIL] : year[1] should be NA (NaT)" << std::endl;
2700 throw std::runtime_error("pd_test_period_array_year_month_quarter failed: year[1] should be NA");
2701 }
2702
2703 auto y2 = years[2];
size (pd_test_1_all.cpp:22)
12#include "../pandas/pd_boolean_array.h"
13
14namespace dataframe_tests {
15
16namespace dataframe_tests_boolean_array {
17 void pd_test_boolean_array_constructors() {
18 std::cout << "========= BooleanArray: constructors ======================= ";
19
20 // Default constructor
21 pandas::BooleanArray arr1;
22 if (arr1.size() != 0) {
23 std::cout << " [FAIL] : in pd_test_boolean_array_constructors() : default constructor size != 0" << std::endl;
24 throw std::runtime_error("pd_test_boolean_array_constructors failed: default constructor size != 0");
25 }
26
27 // Initializer list constructor
28 pandas::BooleanArray arr2({
29 std::optional<bool>(true),
30 std::optional<bool>(false),
31 std::nullopt,
32 std::optional<bool>(true)