|
1 | 1 | import plotly.graph_objs as go |
2 | 2 | import plotly.io as pio |
3 | 3 | from collections import namedtuple, OrderedDict |
4 | | -from collections.abc import Sequence |
5 | 4 | from ._special_inputs import IdentityMap, Constant, Range |
6 | 5 | from .trendline_functions import ols, lowess, rolling, expanding, ewm |
7 | 6 |
|
@@ -182,7 +181,7 @@ def _to_unix_epoch_seconds(s: nw.Series) -> nw.Series: |
182 | 181 | raise TypeError(msg) |
183 | 182 |
|
184 | 183 |
|
185 | | -def _generate_temporary_column_name(n_bytes: int, columns: list[str]) -> str: |
| 184 | +def _generate_temporary_column_name(n_bytes, columns) -> str: |
186 | 185 | """Wraps of Narwhals generate_temporary_column_name to generate a token |
187 | 186 | which is guaranteed to not be in columns, nor in [col + token for col in columns] |
188 | 187 | """ |
@@ -2013,13 +2012,16 @@ def post_agg(dframe: nw.LazyFrame, continuous_aggs, discrete_aggs) -> nw.LazyFra |
2013 | 2012 | - discrete_aggs is either [args["color"], <rest_of_cols>] or [<rest_of cols>] |
2014 | 2013 | """ |
2015 | 2014 | return dframe.with_columns( |
2016 | | - **{col: nw.col(col) / nw.col(count_colname) for col in continuous_aggs}, |
2017 | | - **{ |
2018 | | - col: nw.when(nw.col(f"{col}{n_unique_token}") == 1) |
2019 | | - .then(nw.col(col)) |
2020 | | - .otherwise(nw.lit("(?)")) |
| 2015 | + *[nw.col(col) / nw.col(count_colname) for col in continuous_aggs], |
| 2016 | + *[ |
| 2017 | + ( |
| 2018 | + nw.when(nw.col(f"{col}{n_unique_token}") == 1) |
| 2019 | + .then(nw.col(col)) |
| 2020 | + .otherwise(nw.lit("(?)")) |
| 2021 | + .alias(col) |
| 2022 | + ) |
2021 | 2023 | for col in discrete_aggs |
2022 | | - }, |
| 2024 | + ], |
2023 | 2025 | ).drop([f"{col}{n_unique_token}" for col in discrete_aggs]) |
2024 | 2026 |
|
2025 | 2027 | for i, level in enumerate(path): |
|
0 commit comments