#37530 CLN: Use ABCNDFrame instead of ABCDataFrame and ABCSeries

Open Richard rhshadrach Pseudo commit used to compare (db0cd36...b19e47f)
Missing base report.

Unable to compare commits because the base of the pull request did not upload a coverage report.

Changes found in between db0cd36...b19e47f (pseudo...base) which prevent comparing this pull request.


@@ -21,6 +21,7 @@
Loading
21 21
22 22
import pandas.core.common as com
23 23
from pandas.core.frame import _shared_docs
24 +
from pandas.core.generic import NDFrame
24 25
from pandas.core.groupby import Grouper
25 26
from pandas.core.indexes.api import Index, MultiIndex, get_objs_combined_axis
26 27
from pandas.core.reshape.concat import concat
@@ -585,7 +586,7 @@
Loading
585 586
    colnames = _get_names(columns, colnames, prefix="col")
586 587
587 588
    common_idx = None
588 -
    pass_objs = [x for x in index + columns if isinstance(x, (ABCSeries, ABCDataFrame))]
589 +
    pass_objs = [x for x in index + columns if isinstance(x, NDFrame)]
589 590
    if pass_objs:
590 591
        common_idx = get_objs_combined_axis(pass_objs, intersect=True, sort=False)
591 592

@@ -42,8 +42,8 @@
Loading
42 42
from pandas.core.dtypes.generic import (
43 43
    ABCDataFrame,
44 44
    ABCDatetimeIndex,
45 +
    ABCNDFrame,
45 46
    ABCPeriodIndex,
46 -
    ABCSeries,
47 47
    ABCTimedeltaIndex,
48 48
)
49 49
from pandas.core.dtypes.missing import notna
@@ -144,7 +144,7 @@
Loading
144 144
            "neither",
145 145
        ]:
146 146
            raise ValueError("closed must be 'right', 'left', 'both' or 'neither'")
147 -
        if not isinstance(self.obj, (ABCSeries, ABCDataFrame)):
147 +
        if not isinstance(self.obj, ABCNDFrame):
148 148
            raise TypeError(f"invalid type: {type(self)}")
149 149
        if isinstance(self.window, BaseIndexer):
150 150
            # Validate that the passed BaseIndexer subclass has

@@ -66,7 +66,7 @@
Loading
66 66
import pandas.core.common as com
67 67
from pandas.core.construction import create_series_with_explicit_dtype
68 68
from pandas.core.frame import DataFrame
69 -
from pandas.core.generic import ABCDataFrame, ABCSeries, NDFrame
69 +
from pandas.core.generic import NDFrame
70 70
from pandas.core.groupby import base
71 71
from pandas.core.groupby.groupby import (
72 72
    GroupBy,
@@ -534,7 +534,7 @@
Loading
534 534
            object.__setattr__(group, "name", name)
535 535
            res = func(group, *args, **kwargs)
536 536
537 -
            if isinstance(res, (ABCDataFrame, ABCSeries)):
537 +
            if isinstance(res, NDFrame):
538 538
                res = res._values
539 539
540 540
            results.append(klass(res, index=group.index))

@@ -456,11 +456,9 @@
Loading
456 456
457 457
    # Functions that transform may return empty Series/DataFrame
458 458
    # when the dtype is not appropriate
459 -
    if isinstance(result, (ABCSeries, ABCDataFrame)) and result.empty:
459 +
    if isinstance(result, ABCNDFrame) and result.empty:
460 460
        raise ValueError("Transform function failed")
461 -
    if not isinstance(result, (ABCSeries, ABCDataFrame)) or not result.index.equals(
462 -
        obj.index
463 -
    ):
461 +
    if not isinstance(result, ABCNDFrame) or not result.index.equals(obj.index):
464 462
        raise ValueError("Function did not transform")
465 463
466 464
    return result

@@ -20,7 +20,7 @@
Loading
20 20
from pandas._typing import FrameOrSeriesUnion, Label
21 21
22 22
from pandas.core.dtypes.concat import concat_compat
23 -
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries
23 +
from pandas.core.dtypes.generic import ABCDataFrame, ABCNDFrame, ABCSeries
24 24
from pandas.core.dtypes.missing import isna
25 25
26 26
import pandas.core.algorithms as algos
@@ -317,7 +317,7 @@
Loading
317 317
        copy: bool = True,
318 318
        sort=False,
319 319
    ):
320 -
        if isinstance(objs, (ABCSeries, ABCDataFrame, str)):
320 +
        if isinstance(objs, (ABCNDFrame, str)):
321 321
            raise TypeError(
322 322
                "first argument must be an iterable of pandas "
323 323
                f'objects, you passed an object of type "{type(objs).__name__}"'
@@ -363,7 +363,7 @@
Loading
363 363
        # consolidate data & figure out what our result ndim is going to be
364 364
        ndims = set()
365 365
        for obj in objs:
366 -
            if not isinstance(obj, (ABCSeries, ABCDataFrame)):
366 +
            if not isinstance(obj, ABCNDFrame):
367 367
                msg = (
368 368
                    f"cannot concatenate object of type '{type(obj)}'; "
369 369
                    "only Series and DataFrame objs are valid"

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Unable to process changes.

No base report to compare against.

Files Coverage
pandas 94.23%
Project Totals (215 files) 94.23%
Loading