-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix lower bound of dynamic_groupby of larger intervals (#2711)
- Loading branch information
Showing
13 changed files
with
151 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
/// re-exports for utility | ||
pub use polars_core::export::arrow; | ||
pub use polars_core::export::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use super::*; | ||
use polars::export::chrono::prelude::*; | ||
|
||
#[test] | ||
#[cfg(all( | ||
feature = "temporal", | ||
feature = "dtype-date", | ||
feature = "dynamic_groupby" | ||
))] | ||
fn test_groupby_dynamic_week_bounds() -> Result<()> { | ||
let start = NaiveDate::from_ymd(2022, 2, 1).and_hms(0, 0, 0); | ||
let stop = NaiveDate::from_ymd(2022, 2, 14).and_hms(0, 0, 0); | ||
let range = date_range( | ||
"dt", | ||
start, | ||
stop, | ||
Duration::parse("1d"), | ||
ClosedWindow::Left, | ||
TimeUnit::Milliseconds, | ||
) | ||
.into_series(); | ||
|
||
let a = Int32Chunked::full("a", 1, range.len()); | ||
let df = df![ | ||
"dt" => range, | ||
"a" => a | ||
]?; | ||
|
||
let out = df | ||
.lazy() | ||
.groupby_dynamic( | ||
[], | ||
DynamicGroupOptions { | ||
index_column: "dt".into(), | ||
every: Duration::parse("1w"), | ||
period: Duration::parse("1w"), | ||
offset: Duration::parse("0w"), | ||
closed_window: ClosedWindow::Left, | ||
truncate: false, | ||
include_boundaries: true, | ||
}, | ||
) | ||
.agg([col("a").sum()]) | ||
.collect()?; | ||
let a = out.column("a")?; | ||
assert_eq!(a.get(0), AnyValue::Int32(7)); | ||
assert_eq!(a.get(1), AnyValue::Int32(6)); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod explodes; | ||
mod groupby_dynamic; | ||
mod projection_queries; | ||
mod window_expressions; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters