Skip to content

Commit 6f1389f

Browse files
committed
rm type hints, change post_agg to use alias
1 parent f27f959 commit 6f1389f

File tree

1 file changed

+10
-8
lines changed
  • packages/python/plotly/plotly/express

1 file changed

+10
-8
lines changed

packages/python/plotly/plotly/express/_core.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import plotly.graph_objs as go
22
import plotly.io as pio
33
from collections import namedtuple, OrderedDict
4-
from collections.abc import Sequence
54
from ._special_inputs import IdentityMap, Constant, Range
65
from .trendline_functions import ols, lowess, rolling, expanding, ewm
76

@@ -182,7 +181,7 @@ def _to_unix_epoch_seconds(s: nw.Series) -> nw.Series:
182181
raise TypeError(msg)
183182

184183

185-
def _generate_temporary_column_name(n_bytes: int, columns: list[str]) -> str:
184+
def _generate_temporary_column_name(n_bytes, columns) -> str:
186185
"""Wraps of Narwhals generate_temporary_column_name to generate a token
187186
which is guaranteed to not be in columns, nor in [col + token for col in columns]
188187
"""
@@ -2013,13 +2012,16 @@ def post_agg(dframe: nw.LazyFrame, continuous_aggs, discrete_aggs) -> nw.LazyFra
20132012
- discrete_aggs is either [args["color"], <rest_of_cols>] or [<rest_of cols>]
20142013
"""
20152014
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+
)
20212023
for col in discrete_aggs
2022-
},
2024+
],
20232025
).drop([f"{col}{n_unique_token}" for col in discrete_aggs])
20242026

20252027
for i, level in enumerate(path):

0 commit comments

Comments
 (0)