DataFrameRolling#
-
class pandas::DataFrameRolling#
Window operation class for rolling/expanding calculations.
Example#
#include <pandas/pandas.h>
using namespace pandas;
// Use DataFrameRolling
DataFrameRolling obj;
// ... operations ...
Constructors#
Signature |
Location |
Example |
|---|---|---|
|
pd_dataframe.h:12632 |
Indexing / Selection#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
const DataFrame& |
pd_dataframe.h:12654 |
Statistics#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
size_t |
pd_dataframe.h:12652 |
Aggregation#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
DataFrame |
pd_dataframe.h:12690 |
Other Methods#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
bool |
pd_dataframe.h:12653 |
|
|
Rolling<double> |
pd_dataframe.h:12656 |
|
|
void |
pd_dataframe.h:12645 |
|
|
void |
pd_dataframe.h:12643 |
|
|
void |
pd_dataframe.h:12635 |
|
|
size_t |
pd_dataframe.h:12651 |
Code Examples#
The following examples are extracted from the test suite.
center (pd_test_3_all.cpp:21005)
20995 auto alnum_result = s.str().isalnum();
20996 if (alnum_result[0] != true || alnum_result[1] != true || alnum_result[2] != true || alnum_result[3] != false) {
20997 std::cout << " [FAIL] : isalnum() failed" << std::endl;
20998 throw std::runtime_error("pd_test_str_is_methods: isalnum() failed");
20999 }
21000
21001 std::cout << " -> tests passed" << std::endl;
21002}
21003
21004// ============================================================================
21005// Test str().zfill(), str().center(), str().ljust(), str().rjust()
21006// ============================================================================
21007
21008void pd_test_str_padding() {
21009 std::cout << "========= Series.str().zfill/center/ljust/rjust() =======";
21010
21011 pandas::Series<std::string> s({"1", "22", "333"});
21012
21013 auto zfill_result = s.str().zfill(5);
21014 if (zfill_result[0] != "00001" || zfill_result[1] != "00022" || zfill_result[2] != "00333") {
21015 std::cout << " [FAIL] : zfill() failed" << std::endl;
window (pd_test_1_all.cpp:20977)
20967 }
20968 throw std::runtime_error("pd_test_expanding_corr failed: expanding corr values incorrect");
20969 }
20970
20971 std::cout << " -> tests passed" << std::endl;
20972 }
20973
20974 void pd_test_expanding_skew() {
20975 std::cout << "========= Expanding skew ========================";
20976
20977 // Symmetric data: skew should be 0 at each expanding window (starting from 3)
20978 pandas::Series<double> s({1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0});
20979 auto result = s.expanding().skew();
20980
20981 // First 2 should be NaN (need >= 3 values)
20982 // Symmetric expanding windows [1,2,3], [1,2,3,4], ... all have skew = 0
20983 bool passed = std::isnan(result[0]) &&
20984 std::isnan(result[1]) &&
20985 std::abs(result[2] - 0.0) < 0.001 &&
20986 std::abs(result[3] - 0.0) < 0.001 &&
20987 std::abs(result[4] - 0.0) < 0.001;