From 7e0bda33aa801dc866c040de6b953fa51f9fcd56 Mon Sep 17 00:00:00 2001 From: Swanand01 Date: Fri, 11 Jun 2021 23:41:13 +0530 Subject: [PATCH 01/10] CLN: Replace FrameOrSeriesUnion annotation by DataFrame | Series --- pandas/_typing.py | 6 ---- pandas/core/algorithms.py | 3 +- pandas/core/apply.py | 39 +++++++++++------------ pandas/core/describe.py | 5 ++- pandas/core/frame.py | 23 +++++++------ pandas/core/groupby/generic.py | 7 ++-- pandas/core/groupby/groupby.py | 9 +++--- pandas/core/reshape/concat.py | 11 +++---- pandas/core/reshape/pivot.py | 3 +- pandas/core/series.py | 7 ++-- pandas/core/strings/accessor.py | 5 ++- pandas/core/util/hashing.py | 5 ++- pandas/core/window/ewm.py | 5 ++- pandas/core/window/expanding.py | 7 ++-- pandas/core/window/rolling.py | 31 +++++++++--------- pandas/io/formats/info.py | 5 ++- pandas/io/formats/style.py | 3 +- pandas/io/formats/style_render.py | 5 ++- pandas/io/json/_json.py | 3 +- pandas/io/pytables.py | 7 ++-- pandas/plotting/_matplotlib/timeseries.py | 3 +- pandas/plotting/_matplotlib/tools.py | 4 +-- 22 files changed, 84 insertions(+), 112 deletions(-) diff --git a/pandas/_typing.py b/pandas/_typing.py index 12d23786c3387..906b77319406f 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -101,12 +101,6 @@ ] Timezone = Union[str, tzinfo] -# FrameOrSeriesUnion means either a DataFrame or a Series. E.g. -# `def func(a: FrameOrSeriesUnion) -> FrameOrSeriesUnion: ...` means that if a Series -# is passed in, either a Series or DataFrame is returned, and if a DataFrame is passed -# in, either a DataFrame or a Series is returned. -FrameOrSeriesUnion = Union["DataFrame", "Series"] - # FrameOrSeries is stricter and ensures that the same subclass of NDFrame always is # used. E.g. `def func(a: FrameOrSeries) -> FrameOrSeries: ...` means that if a # Series is passed into a function, a Series is always returned and if a DataFrame is diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index 177dfee0c03ab..e4c5497005ac8 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -29,7 +29,6 @@ AnyArrayLike, ArrayLike, DtypeObj, - FrameOrSeriesUnion, Scalar, ) from pandas.util._decorators import doc @@ -1211,7 +1210,7 @@ def __init__(self, obj, n: int, keep: str): if self.keep not in ("first", "last", "all"): raise ValueError('keep must be either "first", "last" or "all"') - def compute(self, method: str) -> FrameOrSeriesUnion: + def compute(self, method: str) -> DataFrame | Series: raise NotImplementedError def nlargest(self): diff --git a/pandas/core/apply.py b/pandas/core/apply.py index 388c1881afed7..f2e60f43d2a54 100644 --- a/pandas/core/apply.py +++ b/pandas/core/apply.py @@ -25,7 +25,6 @@ AggObjType, Axis, FrameOrSeries, - FrameOrSeriesUnion, ) from pandas.util._decorators import cache_readonly @@ -137,10 +136,10 @@ def f(x): self.f: AggFuncType = f @abc.abstractmethod - def apply(self) -> FrameOrSeriesUnion: + def apply(self) -> DataFrame | Series: pass - def agg(self) -> FrameOrSeriesUnion | None: + def agg(self) -> DataFrame | Series | None: """ Provide an implementation for the aggregators. @@ -171,7 +170,7 @@ def agg(self) -> FrameOrSeriesUnion | None: # caller can react return None - def transform(self) -> FrameOrSeriesUnion: + def transform(self) -> DataFrame | Series: """ Transform a DataFrame or Series. @@ -252,7 +251,7 @@ def transform_dict_like(self, func): func = self.normalize_dictlike_arg("transform", obj, func) - results: dict[Hashable, FrameOrSeriesUnion] = {} + results: dict[Hashable, DataFrame | Series] = {} failed_names = [] all_type_errors = True for name, how in func.items(): @@ -283,7 +282,7 @@ def transform_dict_like(self, func): ) return concat(results, axis=1) - def transform_str_or_callable(self, func) -> FrameOrSeriesUnion: + def transform_str_or_callable(self, func) -> DataFrame | Series: """ Compute transform in the case of a string or callable func """ @@ -305,7 +304,7 @@ def transform_str_or_callable(self, func) -> FrameOrSeriesUnion: except Exception: return func(obj, *args, **kwargs) - def agg_list_like(self) -> FrameOrSeriesUnion: + def agg_list_like(self) -> DataFrame | Series: """ Compute aggregation in the case of a list-like argument. @@ -399,7 +398,7 @@ def agg_list_like(self) -> FrameOrSeriesUnion: ) return concatenated.reindex(full_ordered_index, copy=False) - def agg_dict_like(self) -> FrameOrSeriesUnion: + def agg_dict_like(self) -> DataFrame | Series: """ Compute aggregation in the case of a dict-like argument. @@ -467,7 +466,7 @@ def agg_dict_like(self) -> FrameOrSeriesUnion: return result - def apply_str(self) -> FrameOrSeriesUnion: + def apply_str(self) -> DataFrame | Series: """ Compute apply in case of a string. @@ -492,7 +491,7 @@ def apply_str(self) -> FrameOrSeriesUnion: raise ValueError(f"Operation {f} does not support axis=1") return self._try_aggregate_string_function(obj, f, *self.args, **self.kwargs) - def apply_multiple(self) -> FrameOrSeriesUnion: + def apply_multiple(self) -> DataFrame | Series: """ Compute apply in case of a list-like or dict-like. @@ -504,7 +503,7 @@ def apply_multiple(self) -> FrameOrSeriesUnion: return self.obj.aggregate(self.f, self.axis, *self.args, **self.kwargs) def normalize_dictlike_arg( - self, how: str, obj: FrameOrSeriesUnion, func: AggFuncTypeDict + self, how: str, obj: DataFrame | Series, func: AggFuncTypeDict ) -> AggFuncTypeDict: """ Handler for dict-like argument. @@ -617,7 +616,7 @@ def series_generator(self) -> Iterator[Series]: @abc.abstractmethod def wrap_results_for_axis( self, results: ResType, res_index: Index - ) -> FrameOrSeriesUnion: + ) -> DataFrame | Series: pass # --------------------------------------------------------------- @@ -638,7 +637,7 @@ def values(self): def dtypes(self) -> Series: return self.obj.dtypes - def apply(self) -> FrameOrSeriesUnion: + def apply(self) -> DataFrame | Series: """compute the results""" # dispatch to agg if is_list_like(self.f): @@ -812,7 +811,7 @@ def apply_series_generator(self) -> tuple[ResType, Index]: return results, res_index - def wrap_results(self, results: ResType, res_index: Index) -> FrameOrSeriesUnion: + def wrap_results(self, results: ResType, res_index: Index) -> DataFrame | Series: from pandas import Series # see if we can infer the results @@ -835,7 +834,7 @@ def wrap_results(self, results: ResType, res_index: Index) -> FrameOrSeriesUnion return result - def apply_str(self) -> FrameOrSeriesUnion: + def apply_str(self) -> DataFrame | Series: # Caller is responsible for checking isinstance(self.f, str) # TODO: GH#39993 - Avoid special-casing by replacing with lambda if self.f == "size": @@ -866,7 +865,7 @@ def result_columns(self) -> Index: def wrap_results_for_axis( self, results: ResType, res_index: Index - ) -> FrameOrSeriesUnion: + ) -> DataFrame | Series: """return the results for the rows""" if self.result_type == "reduce": @@ -949,9 +948,9 @@ def result_columns(self) -> Index: def wrap_results_for_axis( self, results: ResType, res_index: Index - ) -> FrameOrSeriesUnion: + ) -> DataFrame | Series: """return the results for the columns""" - result: FrameOrSeriesUnion + result: DataFrame | Series # we have requested to expand if self.result_type == "expand": @@ -1005,7 +1004,7 @@ def __init__( kwargs=kwargs, ) - def apply(self) -> FrameOrSeriesUnion: + def apply(self) -> DataFrame | Series: obj = self.obj if len(obj) == 0: @@ -1056,7 +1055,7 @@ def apply_empty_result(self) -> Series: obj, method="apply" ) - def apply_standard(self) -> FrameOrSeriesUnion: + def apply_standard(self) -> DataFrame | Series: f = self.f obj = self.obj diff --git a/pandas/core/describe.py b/pandas/core/describe.py index dfb18b2c40698..0fd7838ab5acc 100644 --- a/pandas/core/describe.py +++ b/pandas/core/describe.py @@ -22,7 +22,6 @@ from pandas._libs.tslibs import Timestamp from pandas._typing import ( FrameOrSeries, - FrameOrSeriesUnion, Hashable, ) from pandas.util._validators import validate_percentile @@ -107,12 +106,12 @@ class NDFrameDescriberAbstract(ABC): Whether to treat datetime dtypes as numeric. """ - def __init__(self, obj: FrameOrSeriesUnion, datetime_is_numeric: bool): + def __init__(self, obj: DataFrame | Series, datetime_is_numeric: bool): self.obj = obj self.datetime_is_numeric = datetime_is_numeric @abstractmethod - def describe(self, percentiles: Sequence[float]) -> FrameOrSeriesUnion: + def describe(self, percentiles: Sequence[float]) -> DataFrame | Series: """Do describe either series or dataframe. Parameters diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 91b9bdd564676..57b2e701fce35 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -58,7 +58,6 @@ FillnaOptions, FloatFormatType, FormattersType, - FrameOrSeriesUnion, Frequency, IndexKeyFunc, IndexLabel, @@ -1362,7 +1361,7 @@ def dot(self, other: Series) -> Series: def dot(self, other: DataFrame | Index | ArrayLike) -> DataFrame: ... - def dot(self, other: AnyArrayLike | FrameOrSeriesUnion) -> FrameOrSeriesUnion: + def dot(self, other: AnyArrayLike | DataFrame | Series) -> DataFrame | Series: """ Compute the matrix multiplication between the DataFrame and other. @@ -1478,13 +1477,13 @@ def __matmul__(self, other: Series) -> Series: @overload def __matmul__( - self, other: AnyArrayLike | FrameOrSeriesUnion - ) -> FrameOrSeriesUnion: + self, other: AnyArrayLike | DataFrame | Series + ) -> DataFrame | Series: ... def __matmul__( - self, other: AnyArrayLike | FrameOrSeriesUnion - ) -> FrameOrSeriesUnion: + self, other: AnyArrayLike | DataFrame | Series + ) -> DataFrame | Series: """ Matrix multiplication using binary `@` operator in Python>=3.5. """ @@ -8401,8 +8400,8 @@ def _gotitem( self, key: IndexLabel, ndim: int, - subset: FrameOrSeriesUnion | None = None, - ) -> FrameOrSeriesUnion: + subset: DataFrame | Series | None = None, + ) -> DataFrame | Series: """ Sub-classes to define. Return a sliced object. @@ -8931,7 +8930,7 @@ def append( def join( self, - other: FrameOrSeriesUnion, + other: DataFrame | Series, on: IndexLabel | None = None, how: str = "left", lsuffix: str = "", @@ -9061,7 +9060,7 @@ def join( def _join_compat( self, - other: FrameOrSeriesUnion, + other: DataFrame | Series, on: IndexLabel | None = None, how: str = "left", lsuffix: str = "", @@ -9131,7 +9130,7 @@ def _join_compat( @Appender(_merge_doc, indents=2) def merge( self, - right: FrameOrSeriesUnion, + right: DataFrame | Series, how: str = "inner", on: IndexLabel | None = None, left_on: IndexLabel | None = None, @@ -10724,7 +10723,7 @@ def _from_nested_dict(data) -> collections.defaultdict: return new_data -def _reindex_for_setitem(value: FrameOrSeriesUnion, index: Index) -> ArrayLike: +def _reindex_for_setitem(value: DataFrame | Series, index: Index) -> ArrayLike: # reindex if necessary if value.index.equals(index) or not len(index): diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index 69f992f840c7c..d50e921347f98 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -33,7 +33,6 @@ from pandas._typing import ( ArrayLike, FrameOrSeries, - FrameOrSeriesUnion, Manager2D, ) from pandas.util._decorators import ( @@ -296,7 +295,7 @@ def _aggregate_multiple_funcs(self, arg) -> DataFrame: arg = zip(columns, arg) - results: dict[base.OutputKey, FrameOrSeriesUnion] = {} + results: dict[base.OutputKey, DataFrame | Series] = {} for idx, (name, func) in enumerate(arg): key = base.OutputKey(label=name, position=idx) @@ -422,7 +421,7 @@ def _wrap_applied_output( keys: Index, values: list[Any] | None, not_indexed_same: bool = False, - ) -> FrameOrSeriesUnion: + ) -> DataFrame | Series: """ Wrap the output of SeriesGroupBy.apply into the expected result. @@ -1191,7 +1190,7 @@ def _wrap_applied_output_series( not_indexed_same: bool, first_not_none, key_index, - ) -> FrameOrSeriesUnion: + ) -> DataFrame | Series: # this is to silence a DeprecationWarning # TODO: Remove when default dtype of empty Series is object kwargs = first_not_none._construct_axes_dict() diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index f694dcce809ea..90a641a246eb2 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -45,7 +45,6 @@ class providing the base-class of operations. ArrayLike, F, FrameOrSeries, - FrameOrSeriesUnion, IndexLabel, Scalar, T, @@ -728,7 +727,7 @@ def pipe( plot = property(GroupByPlot) @final - def get_group(self, name, obj=None) -> FrameOrSeriesUnion: + def get_group(self, name, obj=None) -> DataFrame | Series: """ Construct DataFrame from group with provided name. @@ -1267,8 +1266,8 @@ def f(g): @final def _python_apply_general( - self, f: F, data: FrameOrSeriesUnion - ) -> FrameOrSeriesUnion: + self, f: F, data: DataFrame | Series + ) -> DataFrame | Series: """ Apply function f in python space @@ -1786,7 +1785,7 @@ def sem(self, ddof: int = 1): @final @Substitution(name="groupby") @Appender(_common_see_also) - def size(self) -> FrameOrSeriesUnion: + def size(self) -> DataFrame | Series: """ Compute group sizes. diff --git a/pandas/core/reshape/concat.py b/pandas/core/reshape/concat.py index ea34bc75b4e31..4952fd5582fdb 100644 --- a/pandas/core/reshape/concat.py +++ b/pandas/core/reshape/concat.py @@ -15,7 +15,6 @@ import numpy as np -from pandas._typing import FrameOrSeriesUnion from pandas.util._decorators import ( cache_readonly, deprecate_nonkeyword_arguments, @@ -83,7 +82,7 @@ def concat( verify_integrity: bool = False, sort: bool = False, copy: bool = True, -) -> FrameOrSeriesUnion: +) -> DataFrame | Series: ... @@ -99,7 +98,7 @@ def concat( verify_integrity: bool = False, sort: bool = False, copy: bool = True, -) -> FrameOrSeriesUnion: +) -> DataFrame | Series: """ Concatenate pandas objects along a particular axis with optional set logic along the other axes. @@ -454,7 +453,7 @@ def __init__( if self._is_frame and axis == 1: name = 0 # mypy needs to know sample is not an NDFrame - sample = cast("FrameOrSeriesUnion", sample) + sample = cast("DataFrame | Series", sample) obj = sample._constructor({name: obj}) self.objs.append(obj) @@ -474,8 +473,8 @@ def __init__( self.new_axes = self._get_new_axes() def get_result(self): - cons: type[FrameOrSeriesUnion] - sample: FrameOrSeriesUnion + cons: type[DataFrame | Series] + sample: DataFrame | Series # series only if self._is_series: diff --git a/pandas/core/reshape/pivot.py b/pandas/core/reshape/pivot.py index 51556fda6da04..d96f2628088a5 100644 --- a/pandas/core/reshape/pivot.py +++ b/pandas/core/reshape/pivot.py @@ -14,7 +14,6 @@ AggFuncType, AggFuncTypeBase, AggFuncTypeDict, - FrameOrSeriesUnion, IndexLabel, ) from pandas.util._decorators import ( @@ -254,7 +253,7 @@ def __internal_pivot_table( def _add_margins( - table: FrameOrSeriesUnion, + table: DataFrame | Series, data, values, rows, diff --git a/pandas/core/series.py b/pandas/core/series.py index 59ea6710ea6cd..5173e98ab8136 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -39,7 +39,6 @@ Dtype, DtypeObj, FillnaOptions, - FrameOrSeriesUnion, IndexKeyFunc, NpDtype, SingleManager, @@ -3022,7 +3021,7 @@ def compare( align_axis: Axis = 1, keep_shape: bool = False, keep_equal: bool = False, - ) -> FrameOrSeriesUnion: + ) -> DataFrame | Series: return super().compare( other=other, align_axis=align_axis, @@ -4178,7 +4177,7 @@ def aggregate(self, func=None, axis=0, *args, **kwargs): ) def transform( self, func: AggFuncType, axis: Axis = 0, *args, **kwargs - ) -> FrameOrSeriesUnion: + ) -> DataFrame | Series: # Validate axis argument self._get_axis_number(axis) result = SeriesApply( @@ -4192,7 +4191,7 @@ def apply( convert_dtype: bool = True, args: tuple[Any, ...] = (), **kwargs, - ) -> FrameOrSeriesUnion: + ) -> DataFrame | Series: """ Invoke function on values of Series. diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index 323cb6bd9fedd..77f53a80dc01e 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -14,8 +14,7 @@ import pandas._libs.lib as lib from pandas._typing import ( - DtypeObj, - FrameOrSeriesUnion, + DtypeObj ) from pandas.util._decorators import Appender @@ -2314,7 +2313,7 @@ def findall(self, pat, flags=0): @forbid_nonstring_types(["bytes"]) def extract( self, pat: str, flags: int = 0, expand: bool = True - ) -> FrameOrSeriesUnion | Index: + ) -> DataFrame | Series | Index: r""" Extract capture groups in the regex `pat` as columns in a DataFrame. diff --git a/pandas/core/util/hashing.py b/pandas/core/util/hashing.py index fb5002648b6a5..601a7f441aa92 100644 --- a/pandas/core/util/hashing.py +++ b/pandas/core/util/hashing.py @@ -16,8 +16,7 @@ from pandas._libs.hashing import hash_object_array from pandas._typing import ( - ArrayLike, - FrameOrSeriesUnion, + ArrayLike ) from pandas.core.dtypes.common import ( @@ -77,7 +76,7 @@ def combine_hash_arrays(arrays: Iterator[np.ndarray], num_items: int) -> np.ndar def hash_pandas_object( - obj: Index | FrameOrSeriesUnion, + obj: Index | DataFrame | Series, index: bool = True, encoding: str = "utf8", hash_key: str | None = _default_hash_key, diff --git a/pandas/core/window/ewm.py b/pandas/core/window/ewm.py index 4187c56079060..84467e9b3e4fb 100644 --- a/pandas/core/window/ewm.py +++ b/pandas/core/window/ewm.py @@ -12,7 +12,6 @@ from pandas._typing import ( Axis, FrameOrSeries, - FrameOrSeriesUnion, TimedeltaConvertibleTypes, ) from pandas.compat.numpy import function as nv @@ -512,7 +511,7 @@ def var_func(values, begin, end, min_periods): ) def cov( self, - other: FrameOrSeriesUnion | None = None, + other: DataFrame | Series | None = None, pairwise: bool | None = None, bias: bool = False, **kwargs, @@ -579,7 +578,7 @@ def cov_func(x, y): ) def corr( self, - other: FrameOrSeriesUnion | None = None, + other: DataFrame | Series | None = None, pairwise: bool | None = None, **kwargs, ): diff --git a/pandas/core/window/expanding.py b/pandas/core/window/expanding.py index 02cf31cad7b8d..85ebe63f88b39 100644 --- a/pandas/core/window/expanding.py +++ b/pandas/core/window/expanding.py @@ -8,8 +8,7 @@ from pandas._typing import ( Axis, - FrameOrSeries, - FrameOrSeriesUnion, + FrameOrSeries ) from pandas.compat.numpy import function as nv from pandas.util._decorators import doc @@ -591,7 +590,7 @@ def quantile( ) def cov( self, - other: FrameOrSeriesUnion | None = None, + other: DataFrame | Series | None = None, pairwise: bool | None = None, ddof: int = 1, **kwargs, @@ -656,7 +655,7 @@ def cov( ) def corr( self, - other: FrameOrSeriesUnion | None = None, + other: DataFrame | Series | None = None, pairwise: bool | None = None, ddof: int = 1, **kwargs, diff --git a/pandas/core/window/rolling.py b/pandas/core/window/rolling.py index 2d5f148a6437a..910e3b6bb6a51 100644 --- a/pandas/core/window/rolling.py +++ b/pandas/core/window/rolling.py @@ -27,8 +27,7 @@ from pandas._typing import ( ArrayLike, Axis, - FrameOrSeries, - FrameOrSeriesUnion, + FrameOrSeries ) from pandas.compat._optional import import_optional_dependency from pandas.compat.numpy import function as nv @@ -408,7 +407,7 @@ def _apply_series( def _apply_blockwise( self, homogeneous_func: Callable[..., ArrayLike], name: str | None = None - ) -> FrameOrSeriesUnion: + ) -> DataFrame | Series: """ Apply the given function to the DataFrame broken down into homogeneous sub-frames. @@ -443,7 +442,7 @@ def hfunc2d(values: ArrayLike) -> ArrayLike: def _apply_tablewise( self, homogeneous_func: Callable[..., ArrayLike], name: str | None = None - ) -> FrameOrSeriesUnion: + ) -> DataFrame | Series: """ Apply the given function to the DataFrame across the entire object """ @@ -460,11 +459,11 @@ def _apply_tablewise( def _apply_pairwise( self, - target: FrameOrSeriesUnion, - other: FrameOrSeriesUnion | None, + target: DataFrame | Series, + other: DataFrame | Series | None, pairwise: bool | None, - func: Callable[[FrameOrSeriesUnion, FrameOrSeriesUnion], FrameOrSeriesUnion], - ) -> FrameOrSeriesUnion: + func: Callable[[DataFrame | Series, DataFrame | Series], DataFrame | Series], + ) -> DataFrame | Series: """ Apply the given pairwise function given 2 pandas objects (DataFrame/Series) """ @@ -639,11 +638,11 @@ def _apply( def _apply_pairwise( self, - target: FrameOrSeriesUnion, - other: FrameOrSeriesUnion | None, + target: DataFrame | Series, + other: DataFrame | Series | None, pairwise: bool | None, - func: Callable[[FrameOrSeriesUnion, FrameOrSeriesUnion], FrameOrSeriesUnion], - ) -> FrameOrSeriesUnion: + func: Callable[[DataFrame | Series, DataFrame | Series], DataFrame | Series], + ) -> DataFrame | Series: """ Apply the given pairwise function given 2 pandas objects (DataFrame/Series) """ @@ -1379,7 +1378,7 @@ def quantile(self, quantile: float, interpolation: str = "linear", **kwargs): def cov( self, - other: FrameOrSeriesUnion | None = None, + other: DataFrame | Series | None = None, pairwise: bool | None = None, ddof: int = 1, **kwargs, @@ -1417,7 +1416,7 @@ def cov_func(x, y): def corr( self, - other: FrameOrSeriesUnion | None = None, + other: DataFrame | Series | None = None, pairwise: bool | None = None, ddof: int = 1, **kwargs, @@ -2159,7 +2158,7 @@ def quantile(self, quantile: float, interpolation: str = "linear", **kwargs): ) def cov( self, - other: FrameOrSeriesUnion | None = None, + other: DataFrame | Series | None = None, pairwise: bool | None = None, ddof: int = 1, **kwargs, @@ -2284,7 +2283,7 @@ def cov( ) def corr( self, - other: FrameOrSeriesUnion | None = None, + other: DataFrame | Series | None = None, pairwise: bool | None = None, ddof: int = 1, **kwargs, diff --git a/pandas/io/formats/info.py b/pandas/io/formats/info.py index e014d7d63a35f..2a2380db8d614 100644 --- a/pandas/io/formats/info.py +++ b/pandas/io/formats/info.py @@ -18,7 +18,6 @@ from pandas._typing import ( Dtype, - FrameOrSeriesUnion, ) from pandas.core.indexes.api import Index @@ -110,7 +109,7 @@ class BaseInfo(ABC): values. """ - data: FrameOrSeriesUnion + data: DataFrame | Series memory_usage: bool | str @property @@ -413,7 +412,7 @@ def get_lines(self) -> list[str]: """Product in a form of list of lines (strings).""" @property - def data(self) -> FrameOrSeriesUnion: + def data(self) -> DataFrame | Series: return self.info.data @property diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 93c3843b36846..6732a4517ec3e 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -23,7 +23,6 @@ Axis, FilePathOrBuffer, FrameOrSeries, - FrameOrSeriesUnion, IndexLabel, Scalar, ) @@ -171,7 +170,7 @@ class Styler(StylerRenderer): def __init__( self, - data: FrameOrSeriesUnion, + data: DataFrame | Series, precision: int | None = None, table_styles: CSSStyles | None = None, uuid: str | None = None, diff --git a/pandas/io/formats/style_render.py b/pandas/io/formats/style_render.py index 7686d8a340c37..9ef29ffcb56b3 100644 --- a/pandas/io/formats/style_render.py +++ b/pandas/io/formats/style_render.py @@ -21,7 +21,6 @@ from pandas._libs import lib from pandas._typing import ( - FrameOrSeriesUnion, TypedDict, ) from pandas.compat._optional import import_optional_dependency @@ -70,7 +69,7 @@ class StylerRenderer: def __init__( self, - data: FrameOrSeriesUnion, + data: DataFrame | Series, uuid: str | None = None, uuid_len: int = 5, table_styles: CSSStyles | None = None, @@ -1159,7 +1158,7 @@ def _pseudo_css(self, uuid: str, name: str, row: int, col: int, text: str): }, ] - def _translate(self, styler_data: FrameOrSeriesUnion, uuid: str, d: dict): + def _translate(self, styler_data: DataFrame | Series, uuid: str, d: dict): """ Mutate the render dictionary to allow for tooltips: diff --git a/pandas/io/json/_json.py b/pandas/io/json/_json.py index 77582c46977c1..fdeda868fdb5e 100644 --- a/pandas/io/json/_json.py +++ b/pandas/io/json/_json.py @@ -21,7 +21,6 @@ from pandas._typing import ( CompressionOptions, DtypeArg, - FrameOrSeriesUnion, IndexLabel, JSONSerializable, StorageOptions, @@ -863,7 +862,7 @@ def __init__( self.convert_dates = convert_dates self.date_unit = date_unit self.keep_default_dates = keep_default_dates - self.obj: FrameOrSeriesUnion | None = None + self.obj: DataFrame | Series | None = None def check_keys_split(self, decoded): """ diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 208b8a008ffe6..3d0a1fe867d21 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -40,7 +40,6 @@ ArrayLike, DtypeArg, FrameOrSeries, - FrameOrSeriesUnion, Shape, ) from pandas.compat._optional import import_optional_dependency @@ -2593,7 +2592,7 @@ class Fixed: pandas_kind: str format_type: str = "fixed" # GH#30962 needed by dask - obj_type: type[FrameOrSeriesUnion] + obj_type: type[DataFrame | Series] ndim: int encoding: str parent: HDFStore @@ -3363,7 +3362,7 @@ def is_multi_index(self) -> bool: return isinstance(self.levels, list) def validate_multiindex( - self, obj: FrameOrSeriesUnion + self, obj: DataFrame | Series ) -> tuple[DataFrame, list[Hashable]]: """ validate that we can store the multi-index; reset and return the @@ -4500,7 +4499,7 @@ class AppendableFrameTable(AppendableTable): pandas_kind = "frame_table" table_type = "appendable_frame" ndim = 2 - obj_type: type[FrameOrSeriesUnion] = DataFrame + obj_type: type[DataFrame | Series] = DataFrame @property def is_transposed(self) -> bool: diff --git a/pandas/plotting/_matplotlib/timeseries.py b/pandas/plotting/_matplotlib/timeseries.py index 3b9c5eae70b42..6d6ac70884423 100644 --- a/pandas/plotting/_matplotlib/timeseries.py +++ b/pandas/plotting/_matplotlib/timeseries.py @@ -16,7 +16,6 @@ to_offset, ) from pandas._libs.tslibs.dtypes import FreqGroup -from pandas._typing import FrameOrSeriesUnion from pandas.core.dtypes.generic import ( ABCDatetimeIndex, @@ -210,7 +209,7 @@ def _get_freq(ax: Axes, series: Series): return freq, ax_freq -def use_dynamic_x(ax: Axes, data: FrameOrSeriesUnion) -> bool: +def use_dynamic_x(ax: Axes, data: DataFrame | Series) -> bool: freq = _get_index_freq(data.index) ax_freq = _get_ax_freq(ax) diff --git a/pandas/plotting/_matplotlib/tools.py b/pandas/plotting/_matplotlib/tools.py index 9bfa24b6371ab..6eb2436b63b61 100644 --- a/pandas/plotting/_matplotlib/tools.py +++ b/pandas/plotting/_matplotlib/tools.py @@ -13,8 +13,6 @@ import matplotlib.ticker as ticker import numpy as np -from pandas._typing import FrameOrSeriesUnion - from pandas.core.dtypes.common import is_list_like from pandas.core.dtypes.generic import ( ABCDataFrame, @@ -55,7 +53,7 @@ def format_date_labels(ax: Axes, rot): def table( - ax, data: FrameOrSeriesUnion, rowLabels=None, colLabels=None, **kwargs + ax, data: DataFrame | Series, rowLabels=None, colLabels=None, **kwargs ) -> Table: if isinstance(data, ABCSeries): data = data.to_frame() From 6bbe77e2c10c5cce48c211c8b77fd2722c81e315 Mon Sep 17 00:00:00 2001 From: Swanand01 Date: Sat, 19 Jun 2021 18:03:37 +0530 Subject: [PATCH 02/10] Import fixes --- pandas/core/strings/accessor.py | 10 ++++++---- pandas/core/util/hashing.py | 5 ++--- pandas/core/window/ewm.py | 8 ++++++-- pandas/core/window/expanding.py | 6 +++++- pandas/io/formats/info.py | 9 +++++---- pandas/plotting/_matplotlib/timeseries.py | 1 + pandas/plotting/_matplotlib/tools.py | 5 +++++ 7 files changed, 30 insertions(+), 14 deletions(-) diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index 77f53a80dc01e..73317cc39c2af 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -13,9 +13,7 @@ import numpy as np import pandas._libs.lib as lib -from pandas._typing import ( - DtypeObj -) +from pandas._typing import DtypeObj from pandas.util._decorators import Appender from pandas.core.dtypes.common import ( @@ -38,7 +36,11 @@ from pandas.core.base import NoNewAttributesMixin if TYPE_CHECKING: - from pandas import Index + from pandas import ( + DataFrame, + Index, + Series, + ) _shared_docs: dict[str, str] = {} _cpython_optimized_encoders = ( diff --git a/pandas/core/util/hashing.py b/pandas/core/util/hashing.py index 601a7f441aa92..03a66225a846f 100644 --- a/pandas/core/util/hashing.py +++ b/pandas/core/util/hashing.py @@ -15,9 +15,7 @@ import numpy as np from pandas._libs.hashing import hash_object_array -from pandas._typing import ( - ArrayLike -) +from pandas._typing import ArrayLike from pandas.core.dtypes.common import ( is_categorical_dtype, @@ -33,6 +31,7 @@ if TYPE_CHECKING: from pandas import ( Categorical, + DataFrame, Index, MultiIndex, Series, diff --git a/pandas/core/window/ewm.py b/pandas/core/window/ewm.py index 1c8879a6a93c2..73de9e072b944 100644 --- a/pandas/core/window/ewm.py +++ b/pandas/core/window/ewm.py @@ -20,6 +20,10 @@ from pandas.core.dtypes.common import is_datetime64_ns_dtype from pandas.core.dtypes.missing import isna +from pandas import ( + DataFrame, + Series, +) import pandas.core.common as common # noqa: PDF018 from pandas.core.util.numba_ import maybe_use_numba from pandas.core.window.common import zsqrt @@ -760,7 +764,7 @@ def std(self, bias: bool = False, *args, **kwargs): def corr( self, - other: FrameOrSeriesUnion | None = None, + other: DataFrame | Series | None = None, pairwise: bool | None = None, **kwargs, ): @@ -768,7 +772,7 @@ def corr( def cov( self, - other: FrameOrSeriesUnion | None = None, + other: DataFrame | Series | None = None, pairwise: bool | None = None, bias: bool = False, **kwargs, diff --git a/pandas/core/window/expanding.py b/pandas/core/window/expanding.py index 85ebe63f88b39..bbe8191bbb4e4 100644 --- a/pandas/core/window/expanding.py +++ b/pandas/core/window/expanding.py @@ -8,11 +8,15 @@ from pandas._typing import ( Axis, - FrameOrSeries + FrameOrSeries, ) from pandas.compat.numpy import function as nv from pandas.util._decorators import doc +from pandas import ( + DataFrame, + Series, +) from pandas.core.window.doc import ( _shared_docs, args_compat, diff --git a/pandas/io/formats/info.py b/pandas/io/formats/info.py index 2a2380db8d614..64a59778a54f3 100644 --- a/pandas/io/formats/info.py +++ b/pandas/io/formats/info.py @@ -16,9 +16,7 @@ from pandas._config import get_option -from pandas._typing import ( - Dtype, -) +from pandas._typing import Dtype from pandas.core.indexes.api import Index @@ -26,7 +24,10 @@ from pandas.io.formats.printing import pprint_thing if TYPE_CHECKING: - from pandas.core.frame import DataFrame + from pandas.core.frame import ( + DataFrame, + Series, + ) def _put_str(s: str | Dtype, space: int) -> str: diff --git a/pandas/plotting/_matplotlib/timeseries.py b/pandas/plotting/_matplotlib/timeseries.py index 6d6ac70884423..3cd312b06020d 100644 --- a/pandas/plotting/_matplotlib/timeseries.py +++ b/pandas/plotting/_matplotlib/timeseries.py @@ -39,6 +39,7 @@ from matplotlib.axes import Axes from pandas import ( + DataFrame, DatetimeIndex, Index, Series, diff --git a/pandas/plotting/_matplotlib/tools.py b/pandas/plotting/_matplotlib/tools.py index 6eb2436b63b61..9d509d02c2e4f 100644 --- a/pandas/plotting/_matplotlib/tools.py +++ b/pandas/plotting/_matplotlib/tools.py @@ -29,6 +29,11 @@ from matplotlib.lines import Line2D from matplotlib.table import Table + from pandas import ( + DataFrame, + Series, + ) + def do_adjust_figure(fig: Figure): """Whether fig has constrained_layout enabled.""" From 1d610ca2990e7de3ca248f2607e950f324b113b4 Mon Sep 17 00:00:00 2001 From: Swanand01 Date: Sat, 19 Jun 2021 18:48:37 +0530 Subject: [PATCH 03/10] Update ewm.py --- pandas/core/window/ewm.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pandas/core/window/ewm.py b/pandas/core/window/ewm.py index 73de9e072b944..af1093a59941d 100644 --- a/pandas/core/window/ewm.py +++ b/pandas/core/window/ewm.py @@ -3,6 +3,7 @@ import datetime from functools import partial from textwrap import dedent +from typing import TYPE_CHECKING import warnings import numpy as np @@ -20,10 +21,12 @@ from pandas.core.dtypes.common import is_datetime64_ns_dtype from pandas.core.dtypes.missing import isna -from pandas import ( - DataFrame, - Series, -) +if TYPE_CHECKING: + from pandas import ( + DataFrame, + Series, + ) + import pandas.core.common as common # noqa: PDF018 from pandas.core.util.numba_ import maybe_use_numba from pandas.core.window.common import zsqrt From 8bee21f4ff656d87e092cebf8aebf5326f74b5e5 Mon Sep 17 00:00:00 2001 From: Swanand01 Date: Sat, 19 Jun 2021 18:48:53 +0530 Subject: [PATCH 04/10] Revert "Update ewm.py" This reverts commit 1d610ca2990e7de3ca248f2607e950f324b113b4. --- pandas/core/window/ewm.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pandas/core/window/ewm.py b/pandas/core/window/ewm.py index af1093a59941d..73de9e072b944 100644 --- a/pandas/core/window/ewm.py +++ b/pandas/core/window/ewm.py @@ -3,7 +3,6 @@ import datetime from functools import partial from textwrap import dedent -from typing import TYPE_CHECKING import warnings import numpy as np @@ -21,12 +20,10 @@ from pandas.core.dtypes.common import is_datetime64_ns_dtype from pandas.core.dtypes.missing import isna -if TYPE_CHECKING: - from pandas import ( - DataFrame, - Series, - ) - +from pandas import ( + DataFrame, + Series, +) import pandas.core.common as common # noqa: PDF018 from pandas.core.util.numba_ import maybe_use_numba from pandas.core.window.common import zsqrt From 76d0dbf1ef5e168aa747e9fb0091948a7bc34d27 Mon Sep 17 00:00:00 2001 From: Swanand01 Date: Sat, 19 Jun 2021 18:49:04 +0530 Subject: [PATCH 05/10] Revert "Import fixes" This reverts commit 6bbe77e2c10c5cce48c211c8b77fd2722c81e315. --- pandas/core/strings/accessor.py | 10 ++++------ pandas/core/util/hashing.py | 5 +++-- pandas/core/window/ewm.py | 8 ++------ pandas/core/window/expanding.py | 6 +----- pandas/io/formats/info.py | 9 ++++----- pandas/plotting/_matplotlib/timeseries.py | 1 - pandas/plotting/_matplotlib/tools.py | 5 ----- 7 files changed, 14 insertions(+), 30 deletions(-) diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index 73317cc39c2af..77f53a80dc01e 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -13,7 +13,9 @@ import numpy as np import pandas._libs.lib as lib -from pandas._typing import DtypeObj +from pandas._typing import ( + DtypeObj +) from pandas.util._decorators import Appender from pandas.core.dtypes.common import ( @@ -36,11 +38,7 @@ from pandas.core.base import NoNewAttributesMixin if TYPE_CHECKING: - from pandas import ( - DataFrame, - Index, - Series, - ) + from pandas import Index _shared_docs: dict[str, str] = {} _cpython_optimized_encoders = ( diff --git a/pandas/core/util/hashing.py b/pandas/core/util/hashing.py index 03a66225a846f..601a7f441aa92 100644 --- a/pandas/core/util/hashing.py +++ b/pandas/core/util/hashing.py @@ -15,7 +15,9 @@ import numpy as np from pandas._libs.hashing import hash_object_array -from pandas._typing import ArrayLike +from pandas._typing import ( + ArrayLike +) from pandas.core.dtypes.common import ( is_categorical_dtype, @@ -31,7 +33,6 @@ if TYPE_CHECKING: from pandas import ( Categorical, - DataFrame, Index, MultiIndex, Series, diff --git a/pandas/core/window/ewm.py b/pandas/core/window/ewm.py index 73de9e072b944..1c8879a6a93c2 100644 --- a/pandas/core/window/ewm.py +++ b/pandas/core/window/ewm.py @@ -20,10 +20,6 @@ from pandas.core.dtypes.common import is_datetime64_ns_dtype from pandas.core.dtypes.missing import isna -from pandas import ( - DataFrame, - Series, -) import pandas.core.common as common # noqa: PDF018 from pandas.core.util.numba_ import maybe_use_numba from pandas.core.window.common import zsqrt @@ -764,7 +760,7 @@ def std(self, bias: bool = False, *args, **kwargs): def corr( self, - other: DataFrame | Series | None = None, + other: FrameOrSeriesUnion | None = None, pairwise: bool | None = None, **kwargs, ): @@ -772,7 +768,7 @@ def corr( def cov( self, - other: DataFrame | Series | None = None, + other: FrameOrSeriesUnion | None = None, pairwise: bool | None = None, bias: bool = False, **kwargs, diff --git a/pandas/core/window/expanding.py b/pandas/core/window/expanding.py index bbe8191bbb4e4..85ebe63f88b39 100644 --- a/pandas/core/window/expanding.py +++ b/pandas/core/window/expanding.py @@ -8,15 +8,11 @@ from pandas._typing import ( Axis, - FrameOrSeries, + FrameOrSeries ) from pandas.compat.numpy import function as nv from pandas.util._decorators import doc -from pandas import ( - DataFrame, - Series, -) from pandas.core.window.doc import ( _shared_docs, args_compat, diff --git a/pandas/io/formats/info.py b/pandas/io/formats/info.py index 64a59778a54f3..2a2380db8d614 100644 --- a/pandas/io/formats/info.py +++ b/pandas/io/formats/info.py @@ -16,7 +16,9 @@ from pandas._config import get_option -from pandas._typing import Dtype +from pandas._typing import ( + Dtype, +) from pandas.core.indexes.api import Index @@ -24,10 +26,7 @@ from pandas.io.formats.printing import pprint_thing if TYPE_CHECKING: - from pandas.core.frame import ( - DataFrame, - Series, - ) + from pandas.core.frame import DataFrame def _put_str(s: str | Dtype, space: int) -> str: diff --git a/pandas/plotting/_matplotlib/timeseries.py b/pandas/plotting/_matplotlib/timeseries.py index 3cd312b06020d..6d6ac70884423 100644 --- a/pandas/plotting/_matplotlib/timeseries.py +++ b/pandas/plotting/_matplotlib/timeseries.py @@ -39,7 +39,6 @@ from matplotlib.axes import Axes from pandas import ( - DataFrame, DatetimeIndex, Index, Series, diff --git a/pandas/plotting/_matplotlib/tools.py b/pandas/plotting/_matplotlib/tools.py index 9d509d02c2e4f..6eb2436b63b61 100644 --- a/pandas/plotting/_matplotlib/tools.py +++ b/pandas/plotting/_matplotlib/tools.py @@ -29,11 +29,6 @@ from matplotlib.lines import Line2D from matplotlib.table import Table - from pandas import ( - DataFrame, - Series, - ) - def do_adjust_figure(fig: Figure): """Whether fig has constrained_layout enabled.""" From 8ffca34af26424d804fc007705dc20b2806cc3f6 Mon Sep 17 00:00:00 2001 From: Swanand01 Date: Sat, 19 Jun 2021 19:10:25 +0530 Subject: [PATCH 06/10] Circular imports fix --- pandas/core/strings/accessor.py | 10 ++++++---- pandas/core/util/hashing.py | 5 ++--- pandas/core/window/ewm.py | 9 +++++++-- pandas/core/window/expanding.py | 7 ++++++- pandas/io/formats/info.py | 9 +++++---- pandas/plotting/_matplotlib/tools.py | 5 +++++ 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index 77f53a80dc01e..73317cc39c2af 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -13,9 +13,7 @@ import numpy as np import pandas._libs.lib as lib -from pandas._typing import ( - DtypeObj -) +from pandas._typing import DtypeObj from pandas.util._decorators import Appender from pandas.core.dtypes.common import ( @@ -38,7 +36,11 @@ from pandas.core.base import NoNewAttributesMixin if TYPE_CHECKING: - from pandas import Index + from pandas import ( + DataFrame, + Index, + Series, + ) _shared_docs: dict[str, str] = {} _cpython_optimized_encoders = ( diff --git a/pandas/core/util/hashing.py b/pandas/core/util/hashing.py index 601a7f441aa92..03a66225a846f 100644 --- a/pandas/core/util/hashing.py +++ b/pandas/core/util/hashing.py @@ -15,9 +15,7 @@ import numpy as np from pandas._libs.hashing import hash_object_array -from pandas._typing import ( - ArrayLike -) +from pandas._typing import ArrayLike from pandas.core.dtypes.common import ( is_categorical_dtype, @@ -33,6 +31,7 @@ if TYPE_CHECKING: from pandas import ( Categorical, + DataFrame, Index, MultiIndex, Series, diff --git a/pandas/core/window/ewm.py b/pandas/core/window/ewm.py index 1c8879a6a93c2..664089fa37b83 100644 --- a/pandas/core/window/ewm.py +++ b/pandas/core/window/ewm.py @@ -3,6 +3,7 @@ import datetime from functools import partial from textwrap import dedent +from typing import TYPE_CHECKING import warnings import numpy as np @@ -14,6 +15,10 @@ FrameOrSeries, TimedeltaConvertibleTypes, ) + +if TYPE_CHECKING: + from pandas import DataFrame, Series + from pandas.compat.numpy import function as nv from pandas.util._decorators import doc @@ -760,7 +765,7 @@ def std(self, bias: bool = False, *args, **kwargs): def corr( self, - other: FrameOrSeriesUnion | None = None, + other: DataFrame | Series | None = None, pairwise: bool | None = None, **kwargs, ): @@ -768,7 +773,7 @@ def corr( def cov( self, - other: FrameOrSeriesUnion | None = None, + other: DataFrame | Series | None = None, pairwise: bool | None = None, bias: bool = False, **kwargs, diff --git a/pandas/core/window/expanding.py b/pandas/core/window/expanding.py index 85ebe63f88b39..eedb6930bad66 100644 --- a/pandas/core/window/expanding.py +++ b/pandas/core/window/expanding.py @@ -2,14 +2,19 @@ from textwrap import dedent from typing import ( + TYPE_CHECKING, Any, Callable, ) from pandas._typing import ( Axis, - FrameOrSeries + FrameOrSeries, ) + +if TYPE_CHECKING: + from pandas import DataFrame, Series + from pandas.compat.numpy import function as nv from pandas.util._decorators import doc diff --git a/pandas/io/formats/info.py b/pandas/io/formats/info.py index 2a2380db8d614..64a59778a54f3 100644 --- a/pandas/io/formats/info.py +++ b/pandas/io/formats/info.py @@ -16,9 +16,7 @@ from pandas._config import get_option -from pandas._typing import ( - Dtype, -) +from pandas._typing import Dtype from pandas.core.indexes.api import Index @@ -26,7 +24,10 @@ from pandas.io.formats.printing import pprint_thing if TYPE_CHECKING: - from pandas.core.frame import DataFrame + from pandas.core.frame import ( + DataFrame, + Series, + ) def _put_str(s: str | Dtype, space: int) -> str: diff --git a/pandas/plotting/_matplotlib/tools.py b/pandas/plotting/_matplotlib/tools.py index 6eb2436b63b61..9d509d02c2e4f 100644 --- a/pandas/plotting/_matplotlib/tools.py +++ b/pandas/plotting/_matplotlib/tools.py @@ -29,6 +29,11 @@ from matplotlib.lines import Line2D from matplotlib.table import Table + from pandas import ( + DataFrame, + Series, + ) + def do_adjust_figure(fig: Figure): """Whether fig has constrained_layout enabled.""" From 7e06259cd473b2c92c4883ad858105b5b2b1d2b3 Mon Sep 17 00:00:00 2001 From: Swanand01 <75439077+Swanand01@users.noreply.github.com> Date: Sat, 19 Jun 2021 21:33:57 +0530 Subject: [PATCH 07/10] Update timeseries.py --- pandas/plotting/_matplotlib/timeseries.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/plotting/_matplotlib/timeseries.py b/pandas/plotting/_matplotlib/timeseries.py index 6d6ac70884423..ee8c756d51c8d 100644 --- a/pandas/plotting/_matplotlib/timeseries.py +++ b/pandas/plotting/_matplotlib/timeseries.py @@ -41,6 +41,7 @@ from pandas import ( DatetimeIndex, Index, + DataFrame, Series, ) From dc704106a219e141a3f23d6cc370d019b5882a87 Mon Sep 17 00:00:00 2001 From: Swanand01 <75439077+Swanand01@users.noreply.github.com> Date: Sun, 20 Jun 2021 20:56:51 +0530 Subject: [PATCH 08/10] Update rolling.py --- pandas/core/window/rolling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/window/rolling.py b/pandas/core/window/rolling.py index 910e3b6bb6a51..31951b3f29a82 100644 --- a/pandas/core/window/rolling.py +++ b/pandas/core/window/rolling.py @@ -27,7 +27,7 @@ from pandas._typing import ( ArrayLike, Axis, - FrameOrSeries + FrameOrSeries, ) from pandas.compat._optional import import_optional_dependency from pandas.compat.numpy import function as nv From 53acbbfe00f75a6444bd018327c89a71238a7fe0 Mon Sep 17 00:00:00 2001 From: Swanand01 <75439077+Swanand01@users.noreply.github.com> Date: Sun, 20 Jun 2021 20:57:54 +0530 Subject: [PATCH 09/10] Update timeseries.py --- pandas/plotting/_matplotlib/timeseries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/plotting/_matplotlib/timeseries.py b/pandas/plotting/_matplotlib/timeseries.py index ee8c756d51c8d..3cd312b06020d 100644 --- a/pandas/plotting/_matplotlib/timeseries.py +++ b/pandas/plotting/_matplotlib/timeseries.py @@ -39,9 +39,9 @@ from matplotlib.axes import Axes from pandas import ( + DataFrame, DatetimeIndex, Index, - DataFrame, Series, ) From 28bd82532106ad8a8aed66f5ab420bcc0e26972a Mon Sep 17 00:00:00 2001 From: Swanand01 <75439077+Swanand01@users.noreply.github.com> Date: Sun, 20 Jun 2021 20:58:42 +0530 Subject: [PATCH 10/10] Update style_render.py --- pandas/io/formats/style_render.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/io/formats/style_render.py b/pandas/io/formats/style_render.py index 9ef29ffcb56b3..f20c8dcfbca8b 100644 --- a/pandas/io/formats/style_render.py +++ b/pandas/io/formats/style_render.py @@ -20,9 +20,7 @@ from pandas._config import get_option from pandas._libs import lib -from pandas._typing import ( - TypedDict, -) +from pandas._typing import TypedDict from pandas.compat._optional import import_optional_dependency from pandas.core.dtypes.generic import ABCSeries