Skip to content

Commit

Permalink
Update polars to 0.33 (#10672)
Browse files Browse the repository at this point in the history
# Description
Open question:

Undocumented behavior for the new argument `ambiguous` to the
`as_datetime`
methods. I cheated by passing a default (assuming empty string).
This appears like an API primarily serving the python impl:


https://pola-rs.github.io/polars/py-polars/html/reference/expressions/api/polars.Expr.str.to_datetime.html#polars-expr-str-to-datetime


# User-Facing Changes
Only dependent on breaking changes to the behavior of polars.

# Tests + Formatting
No observed changes to tests

Manually checked `dfr as-datetime`, doesn't seem to panic.
  • Loading branch information
sholderbach authored Oct 11, 2023
1 parent c5545c5 commit c925537
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 54 deletions.
91 changes: 49 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions crates/nu-cmd-dataframe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ indexmap = { version = "2.0" }
num = { version = "0.4", optional = true }
serde = { version = "1.0", features = ["derive"] }
sqlparser = { version = "0.36.1", optional = true }
polars-io = { version = "0.32", features = ["avro"], optional = true }
polars-io = { version = "0.33", features = ["avro"], optional = true }

[dependencies.polars]
features = [
Expand All @@ -38,7 +38,7 @@ features = [
"dtype-categorical",
"dtype-datetime",
"dtype-struct",
"dynamic_groupby",
"dynamic_group_by",
"ipc",
"is_in",
"json",
Expand All @@ -54,7 +54,7 @@ features = [
"to_dummies",
]
optional = true
version = "0.32"
version = "0.33"

[features]
dataframe = ["num", "polars", "polars-io", "sqlparser"]
Expand Down
2 changes: 1 addition & 1 deletion crates/nu-cmd-dataframe/src/dataframe/eager/sql_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl SQLContext {
.enumerate()
.map(|(agg_pj, (proj_p, expr))| (expr.clone(), (proj_p, agg_pj + group_by.len())))
.unzip();
let agg_df = df.groupby(group_by).agg(agg_projection);
let agg_df = df.group_by(group_by).agg(agg_projection);
let mut final_proj_pos = groupby_pos
.into_iter()
.chain(agg_proj_pos)
Expand Down
2 changes: 1 addition & 1 deletion crates/nu-cmd-dataframe/src/dataframe/lazy/groupby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl Command for ToLazyGroupBy {
let group_by = NuLazyGroupBy {
schema: lazy.schema.clone(),
from_eager: lazy.from_eager,
group_by: Some(lazy.into_polars().groupby(&expressions)),
group_by: Some(lazy.into_polars().group_by(&expressions)),
};

Ok(PipelineData::Value(group_by.into_value(call.head), None))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ fn command(
TimeUnit::Nanoseconds,
false,
None,
None,
&Default::default(),
)
} else {
casted.as_datetime(
Expand All @@ -157,7 +157,7 @@ fn command(
false,
false,
None,
None,
&Default::default(),
)
};

Expand Down
8 changes: 3 additions & 5 deletions crates/nu-cmd-dataframe/src/dataframe/series/masks/is_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use nu_protocol::{
engine::{Command, EngineState, Stack},
Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value,
};
use polars::prelude::IntoSeries;
use polars::prelude::{is_in, IntoSeries};

#[derive(Clone)]
pub struct IsIn;
Expand Down Expand Up @@ -71,16 +71,14 @@ fn command(
call: &Call,
input: PipelineData,
) -> Result<PipelineData, ShellError> {
let df = NuDataFrame::try_from_pipeline(input, call.head)?;
let df = NuDataFrame::try_from_pipeline(input, call.head)?.as_series(call.head)?;

let other_value: Value = call.req(engine_state, stack, 0)?;
let other_span = other_value.span();
let other_df = NuDataFrame::try_from_value(other_value)?;
let other = other_df.as_series(other_span)?;

let mut res = df
.as_series(call.head)?
.is_in(&other)
let mut res = is_in(&df, &other)
.map_err(|e| {
ShellError::GenericError(
"Error finding in other".into(),
Expand Down

0 comments on commit c925537

Please sign in to comment.