mirror of https://github.com/apache/superset.git
perf(postprocessing): improve pivot postprocessing operation (#23465)
Co-authored-by: Usiel Riedl <usiel.riedl@automattic.com>
This commit is contained in:
parent
d1947f7354
commit
be2eb3157c
|
@ -87,7 +87,7 @@ def pivot( # pylint: disable=too-many-arguments,too-many-locals
|
|||
if not drop_missing_columns and columns:
|
||||
for row in df[columns].itertuples():
|
||||
for metric in aggfunc.keys():
|
||||
series_set.add(str(tuple([metric]) + tuple(row[1:])))
|
||||
series_set.add(tuple([metric]) + tuple(row[1:]))
|
||||
|
||||
df = df.pivot_table(
|
||||
values=aggfunc.keys(),
|
||||
|
@ -101,10 +101,7 @@ def pivot( # pylint: disable=too-many-arguments,too-many-locals
|
|||
)
|
||||
|
||||
if not drop_missing_columns and len(series_set) > 0 and not df.empty:
|
||||
for col in df.columns:
|
||||
series = str(col)
|
||||
if series not in series_set:
|
||||
df = df.drop(col, axis=PandasAxis.COLUMN)
|
||||
df = df.drop(df.columns.difference(series_set), axis=PandasAxis.COLUMN)
|
||||
|
||||
if combine_value_with_metric:
|
||||
df = df.stack(0).unstack()
|
||||
|
|
Loading…
Reference in New Issue