Skip to content

Commit 0888edc

Browse files
committed
catch up with Polars
1 parent f4ac524 commit 0888edc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

data_algebra/polars_model.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ def get_cell(self, *, d, row: int, colname: str):
637637

638638
def set_col(self, *, d, colname: str, values):
639639
"""set column, return ref"""
640-
d2 = d.with_column(pl.Series(values=values).alias(colname))
640+
d2 = d.with_columns([pl.Series(values=values).alias(colname)])
641641
return d2
642642

643643
def table_is_keyed_by_columns(self, table, *, column_names: Iterable[str]) -> bool:
@@ -667,7 +667,7 @@ def table_is_keyed_by_columns(self, table, *, column_names: Iterable[str]) -> bo
667667
mx = (
668668
table
669669
.select(column_names)
670-
.with_column(pl.lit(1, pl.Int64).alias("_da_count_tmp"))
670+
.with_columns([pl.lit(1, pl.Int64).alias("_da_count_tmp")])
671671
.groupby(column_names)
672672
.sum()["_da_count_tmp"]
673673
.max()
@@ -720,8 +720,8 @@ def _concat_rows_step(self, op: data_algebra.data_ops_types.OperatorPlatform, *,
720720
assert len(inputs) == 2
721721
inputs = [input_i.select(common_columns) for input_i in inputs] # get columns in same order
722722
if op.id_column is not None:
723-
inputs[0] = inputs[0].with_column(_build_lit(op.a_name).alias(op.id_column))
724-
inputs[1] = inputs[1].with_column(_build_lit(op.b_name).alias(op.id_column))
723+
inputs[0] = inputs[0].with_columns([_build_lit(op.a_name).alias(op.id_column)])
724+
inputs[1] = inputs[1].with_columns([_build_lit(op.b_name).alias(op.id_column)])
725725
res = pl.concat(inputs, how="vertical")
726726
return res
727727

@@ -799,7 +799,7 @@ def _extend_step(self, op: data_algebra.data_ops_types.OperatorPlatform, *, data
799799
if c not in partition_set:
800800
order_cols.append(c)
801801
reversed_cols = [True if ci in set(op.reverse) else False for ci in op.order_by]
802-
res = res.sort(by=op.order_by, reverse=reversed_cols)
802+
res = res.sort(by=op.order_by, descending=reversed_cols)
803803
res = res.with_columns(produced_columns)
804804
if len(temp_v_columns) > 0:
805805
res = res.select(op.columns_produced())
@@ -865,7 +865,7 @@ def _project_step(self, op: data_algebra.data_ops_types.OperatorPlatform, *, dat
865865
res = res.collect()
866866
if res.shape[0] <= 0:
867867
# make an all None frame
868-
res = pl.DataFrame({c: [None] for c in res.columns}, columns=[(res.columns[j], res.dtypes[j]) for j in range(res.shape[1])])
868+
res = pl.DataFrame({c: [None] for c in res.columns}, schema=[(res.columns[j], res.dtypes[j]) for j in range(res.shape[1])])
869869
# see if we need to convert to lazy type
870870
if self.use_lazy_eval and isinstance(res, pl.DataFrame):
871871
res = res.lazy()
@@ -952,7 +952,7 @@ def _order_rows_step(self, op: data_algebra.data_ops_types.OperatorPlatform, *,
952952
)
953953
res = self._compose_polars_ops(op.sources[0], data_map=data_map)
954954
reversed_cols = [True if ci in set(op.reverse) else False for ci in op.order_columns]
955-
res = res.sort(by=op.order_columns, reverse=reversed_cols)
955+
res = res.sort(by=op.order_columns, descending=reversed_cols)
956956
if op.limit is not None:
957957
res = res.head(op.limit)
958958
return res

0 commit comments

Comments
 (0)