mirror of
https://github.com/elastic/eland.git
synced 2025-07-11 00:02:14 +08:00
Add try_sort() to eland.utils
This function was deprecated and removed in Pandas v1.1
This commit is contained in:
parent
c6bf9b60a0
commit
92170c22d9
@ -16,10 +16,10 @@
|
||||
# under the License.
|
||||
|
||||
import numpy as np
|
||||
import pandas.core.common as com
|
||||
from pandas.core.dtypes.generic import ABCIndexClass
|
||||
from pandas.plotting._matplotlib import converter
|
||||
from pandas.plotting._matplotlib.tools import _flatten, _set_ticks_props, _subplots
|
||||
from eland.utils import try_sort
|
||||
|
||||
|
||||
def hist_series(
|
||||
@ -120,7 +120,7 @@ def hist_frame(
|
||||
)
|
||||
_axes = _flatten(axes)
|
||||
|
||||
for i, col in enumerate(com.try_sort(data.columns)):
|
||||
for i, col in enumerate(try_sort(data.columns)):
|
||||
ax = _axes[i]
|
||||
ax.hist(
|
||||
ed_df_bins[col][:-1],
|
||||
|
@ -18,7 +18,7 @@
|
||||
import re
|
||||
import functools
|
||||
import warnings
|
||||
from typing import Callable, TypeVar, Any, Union, List, cast, Collection
|
||||
from typing import Callable, TypeVar, Any, Union, List, cast, Collection, Iterable
|
||||
from collections.abc import Collection as ABCCollection
|
||||
import pandas as pd # type: ignore
|
||||
|
||||
@ -59,3 +59,13 @@ def to_list(x: Union[Collection[Any], pd.Series]) -> List[Any]:
|
||||
elif isinstance(x, pd.Series):
|
||||
return cast(List[Any], x.to_list())
|
||||
raise NotImplementedError(f"Could not convert {type(x).__name__} into a list")
|
||||
|
||||
|
||||
def try_sort(iterable: Iterable[Item]) -> Iterable[Item]:
|
||||
# Pulled from pandas.core.common since
|
||||
# it was deprecated and removed in 1.1
|
||||
listed = list(iterable)
|
||||
try:
|
||||
return sorted(listed)
|
||||
except TypeError:
|
||||
return listed
|
||||
|
Loading…
x
Reference in New Issue
Block a user