PandasOptions#
-
class pandas::PandasOptions#
Utility class for pandas operations.
Example#
#include <pandas/pandas.h>
using namespace pandas;
// Use PandasOptions
PandasOptions obj;
// ... operations ...
Indexing / Selection#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
T |
pd_top_level.h:203 |
Statistics#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
std::string |
pd_top_level.h:240 |
Other Methods#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
static PandasOptions& |
pd_top_level.h:197 |
|
|
std::vector<std::string> |
pd_top_level.h:281 |
|
|
void |
pd_top_level.h:228 |
|
|
void |
pd_top_level.h:236 |
|
|
void |
pd_top_level.h:216 |
Code Examples#
The following examples are extracted from the test suite.
get (pd_test_1_all.cpp:10290)
10280void pd_test_extension_index_get_loc_unique() {
10281 std::cout << "========= get_loc (unique) =========================";
10282
10283 pandas::CategoricalArray arr({"apple", "banana", "cherry"});
10284 pandas::CategoricalIndex idx(arr);
10285
10286 auto loc_apple = idx.get_loc("apple");
10287 auto loc_banana = idx.get_loc("banana");
10288 auto loc_cherry = idx.get_loc("cherry");
10289
10290 bool passed = (std::holds_alternative<size_t>(loc_apple) && std::get<size_t>(loc_apple) == 0 &&
10291 std::get<size_t>(loc_banana) == 1 &&
10292 std::get<size_t>(loc_cherry) == 2);
10293 if (!passed) {
10294 std::cout << " [FAIL] : in pd_test_extension_index_get_loc_unique() : get_loc check failed" << std::endl;
10295 throw std::runtime_error("pd_test_extension_index_get_loc_unique failed");
10296 }
10297
10298 std::cout << " -> tests passed" << std::endl;
10299}
describe (pd_test_2_all.cpp:19793)
19783 ++g_fail;
19784 }
19785}
19786
19787static bool approx_eq(double a, double b, double tol = 1e-9) {
19788 if (std::isnan(a) && std::isnan(b)) return true;
19789 return std::abs(a - b) < tol;
19790}
19791
19792// =====================================================================
19793// Test: describe() default mode — numeric columns only
19794// =====================================================================
19795
19796void pd_test_describe_numeric_only() {
19797 std::cout << " -- pd_test_describe_numeric_only --" << std::endl;
19798
19799 pandas::DataFrame df;
19800 df.add_column("A", std::vector<double>{1.0, 2.0, 3.0, 4.0, 5.0});
19801 df.add_column("B", std::vector<double>{10.0, 20.0, 30.0, 40.0, 50.0});
19802 df.add_column("Name", std::vector<std::string>{"a", "b", "c", "d", "e"});
reset (pd_test_1_all.cpp:16254)
16244 // Test copy
16245 pandas::Flags f4 = f2;
16246 passed = f4 == f2;
16247 if (!passed) {
16248 std::cout << " [FAIL] : in pd_test_ndframe_flags() : copy constructor" << std::endl;
16249 throw std::runtime_error("pd_test_ndframe_flags failed: copy constructor");
16250 }
16251
16252 // Test reset
16253 f4.reset();
16254 passed = f4.allows_duplicate_labels == true && f4.copy_on_write == false;
16255 if (!passed) {
16256 std::cout << " [FAIL] : in pd_test_ndframe_flags() : reset()" << std::endl;
16257 throw std::runtime_error("pd_test_ndframe_flags failed: reset()");
16258 }
16259
16260 std::cout << " -> tests passed" << std::endl;
16261 }
16262
16263 // =====================================================================
set (pd_test_1_all.cpp:16281)
16271 pandas::Attrs attrs;
16272
16273 // Test empty
16274 bool passed = attrs.empty() && attrs.size() == 0;
16275 if (!passed) {
16276 std::cout << " [FAIL] : in pd_test_ndframe_attrs() : empty attrs" << std::endl;
16277 throw std::runtime_error("pd_test_ndframe_attrs failed: empty attrs");
16278 }
16279
16280 // Test set/get string
16281 attrs.set("author", std::string("John Doe"));
16282 passed = attrs.contains("author") && attrs.get<std::string>("author") == "John Doe";
16283 if (!passed) {
16284 std::cout << " [FAIL] : in pd_test_ndframe_attrs() : set/get string" << std::endl;
16285 throw std::runtime_error("pd_test_ndframe_attrs failed: set/get string");
16286 }
16287
16288 // Test set/get double
16289 attrs.set("version", 1.5);
16290 passed = std::abs(attrs.get<double>("version") - 1.5) < 1e-10;
16291 if (!passed) {