-
-
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.
compare expand_cols by variant not exact datatype (#3050)
- Loading branch information
Showing
3 changed files
with
46 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use super::*; | ||
use polars::export::chrono::{NaiveDate, NaiveDateTime}; | ||
|
||
#[test] | ||
fn test_expand_datetimes_3042() -> Result<()> { | ||
let low = NaiveDate::from_ymd(2020, 1, 1).and_hms(0, 0, 0); | ||
let high = NaiveDate::from_ymd(2020, 2, 1).and_hms(0, 0, 0); | ||
let date_range = date_range( | ||
"dt1", | ||
low, | ||
high, | ||
Duration::parse("1w"), | ||
ClosedWindow::Left, | ||
TimeUnit::Milliseconds, | ||
) | ||
.into_series(); | ||
|
||
let out = df![ | ||
"dt1" => date_range.clone(), | ||
"dt2" => date_range, | ||
]? | ||
.lazy() | ||
// this tests if we expand datetimes even though the units differ | ||
.with_column( | ||
dtype_col(&DataType::Datetime(TimeUnit::Microseconds, None)) | ||
.dt() | ||
.strftime("%m/%d/%Y"), | ||
) | ||
.limit(3) | ||
.collect()?; | ||
|
||
let expected = df![ | ||
"dt1" => ["01/01/2020", "01/08/2020", "01/15/2020"], | ||
"dt2" => ["01/01/2020", "01/08/2020", "01/15/2020"], | ||
]?; | ||
assert!(out.frame_equal(&expected)); | ||
|
||
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,5 +1,6 @@ | ||
mod apply; | ||
mod arity; | ||
mod expand; | ||
mod is_in; | ||
mod slice; | ||
mod window; | ||
|