Path: blob/main/py-polars/tests/unit/dataframe/test_window.py
8405 views
import polars as pl1from polars.testing import assert_frame_equal234def test_single_row_literal_ambiguity_8481() -> None:5df = pl.DataFrame(6{7"store_id": [1],8"cost_price": [2.0],9}10)1112inverse_cost_price = 1.0 / pl.col("cost_price")13result = df.with_columns(14(inverse_cost_price / inverse_cost_price.sum()).over("store_id").alias("result")15)16# exceptions.ComputeError: cannot aggregate a literal1718expected = pl.DataFrame(19{20"store_id": [1],21"cost_price": [2.0],22"result": [1.0],23}24)25assert_frame_equal(result, expected)262728