mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
chore: remove deprecated distutils (#24001)
This commit is contained in:
committed by
GitHub
parent
c9a0694116
commit
c963416c09
@@ -15,10 +15,10 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from typing import Sequence, Union
|
||||
from collections.abc import Iterable
|
||||
from typing import Any, Sequence, Union
|
||||
|
||||
import pandas as pd
|
||||
from numpy.distutils.misc_util import is_sequence
|
||||
|
||||
from superset.utils.pandas_postprocessing.utils import (
|
||||
_is_multi_index_on_columns,
|
||||
@@ -27,6 +27,13 @@ from superset.utils.pandas_postprocessing.utils import (
|
||||
)
|
||||
|
||||
|
||||
def is_sequence(seq: Any) -> bool:
|
||||
if isinstance(seq, str):
|
||||
return False
|
||||
|
||||
return isinstance(seq, Iterable)
|
||||
|
||||
|
||||
def flatten(
|
||||
df: pd.DataFrame,
|
||||
reset_index: bool = True,
|
||||
@@ -85,7 +92,7 @@ def flatten(
|
||||
_columns = []
|
||||
for series in df.columns.to_flat_index():
|
||||
_cells = []
|
||||
for cell in series if is_sequence(series) else [series]: # type: ignore
|
||||
for cell in series if is_sequence(series) else [series]:
|
||||
if pd.notnull(cell):
|
||||
# every cell should be converted to string and escape comma
|
||||
_cells.append(escape_separator(str(cell)))
|
||||
|
||||
Reference in New Issue
Block a user