pct_change().over(["symbol_id", "time_id"]).name.suffix("_pct_change_1"), ) check_result(data_delta, ["responder_1", "responder_1_diff_1"], ["symbol_id", "time_id"]) check_result(data_delta, ["responder_1", "responder_1_pct_change_1"], ["symbol_id", "time_id"]) ...
%timeit df_pandas.assign(GE_Return=df_pandas["GE"].pct_change()) # 3.67 ms ± 23.5 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) # polars %timeit df_polars.with_columns((pl.col("GE").pct_change()).alias("GE_return")) # 89 µs ± 3.57 µs per loop...
pct_change = ["polars-ops/pct_change", "polars-lazy?/pct_change"] peaks = ["polars-lazy/peaks"] pivot = ["polars-lazy?/pivot"] pivot = ["polars-lazy?/pivot", "polars-ops/pivot", "dtype-struct", "rows"] product = ["polars-core/product"] propagate_nans = ["polars-lazy?/prop...
"pct_change", 8 changes: 6 additions & 2 deletions 8 crates/polars-plan/Cargo.toml Original file line numberDiff line numberDiff line change @@ -88,7 +88,6 @@ dtype-array = ["polars-core/dtype-array", "polars-ops/dtype-array"] dtype-categorical = ["polars-core/dtype-categorical"...
df.with_columns((pl.col("quantity")/pl.col("quantity").sum()).alias("pct_total")) In this example we divide the line item quantity by the total quantitypl.col("quantity").sum()and label it aspct_total. You may have noticed that the previousmonth_namecolumn is not there. That’s...
'feature="pct_change"' --cfg 'feature="performant"' --cfg 'feature="private"' --cfg 'feature="product"' --cfg 'feature="rand"' --cfg 'feature="rand_distr"' --cfg 'feature="random"' --cfg 'feature="rank"' --cfg 'feature="regex"' --cfg 'feature="reinterpret"' --cfg '...
"pct_change", "moment", "arange", "true_div", "dtype-categorical", "string_justify", Expand Down Expand Up @@ -95,7 +93,7 @@ features = [ "timezones", ] git = "https://github.com/pola-rs/polars.git" rev = "ee2366b68f35c4b69dfe34cbf1eae107d4ebe97b" rev = "672922491bac...
df=df.sort_values(by="date")df["pct_change"]=df["v"].pct_change()returndfdf=df.groupby("asset",as_index=False).apply(fun)# 如果使用polars的话df.groupby("asset").agg([pl.all().first(),pl.col("v").sort_by("date").pct_change().alias("pct_change")]).explode("pct_change"...
Original file line numberDiff line numberDiff line change @@ -1,6 +1,6 @@ use polars::prelude::*; fn main() -> Result<()> { fn main() -> PolarsResult<()> { let df = LazyFrame::scan_parquet("../datasets/foods1.parquet", ScanArgsParquet::default())? .select([ // select...
pct_exprs = [] for p in quantiles: if is_numeric or is_temporal: pct_expr = ( F.col(c).to_physical().quantile(p, interpolation).cast(dtype) if is_temporal else F.col(c).quantile(p, interpolation) ) sort_cols.add(c) else: pct_expr = null pct_exprs.append(pct_expr.alias(f"...