-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(rust): move replace_time_zone to polars-ops
- Loading branch information
1 parent
700b965
commit d713826
Showing
13 changed files
with
92 additions
and
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mod replace_time_zone; | ||
#[cfg(feature = "timezones")] | ||
pub use replace_time_zone::*; |
24 changes: 24 additions & 0 deletions
24
polars/polars-ops/src/chunked_array/datetime/replace_time_zone.rs
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,24 @@ | ||
use polars_arrow::kernels::replace_time_zone as replace_time_zone_kernel; | ||
use polars_core::prelude::*; | ||
|
||
pub fn replace_time_zone( | ||
series: &DatetimeChunked, | ||
time_zone: Option<&str>, | ||
use_earliest: Option<bool>, | ||
) -> PolarsResult<DatetimeChunked> { | ||
let out: PolarsResult<_> = { | ||
let from = series.time_zone().as_deref().unwrap_or("UTC"); | ||
let to = time_zone.unwrap_or("UTC"); | ||
let chunks = series | ||
.downcast_iter() | ||
.map(|arr| { | ||
replace_time_zone_kernel(arr, series.time_unit().to_arrow(), from, to, use_earliest) | ||
}) | ||
.collect::<PolarsResult<_>>()?; | ||
let out = unsafe { ChunkedArray::from_chunks(series.name(), chunks) }; | ||
Ok(out.into_datetime(series.time_unit(), time_zone.map(|x| x.to_string()))) | ||
}; | ||
let mut out = out?; | ||
out.set_sorted_flag(series.is_sorted_flag()); | ||
Ok(out) | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.