diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index d38ee7b8b589a..ca9fe0fe60faf 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -249,6 +249,7 @@ Other API Changes - Comparing :class:`Timestamp` with unsupported objects now returns :py:obj:`NotImplemented` instead of raising ``TypeError``. This implies that unsupported rich comparisons are delegated to the other object, and are now consistent with Python 3 behavior for ``datetime`` objects (:issue:`24011`) - Bug in :meth:`DatetimeIndex.snap` which didn't preserving the ``name`` of the input :class:`Index` (:issue:`25575`) - The ``arg`` argument in :meth:`pandas.core.groupby.DataFrameGroupBy.agg` has been renamed to ``func`` (:issue:`26089`) +- The ``arg`` argument in :meth:`pandas.core.window._Window.aggregate` has been renamed to ``func`` (:issue:`26372`) .. _whatsnew_0250.deprecations: diff --git a/mypy.ini b/mypy.ini index e1111c7ba7f66..584c747a26f2e 100644 --- a/mypy.ini +++ b/mypy.ini @@ -15,37 +15,4 @@ ignore_errors=True ignore_errors=True [mypy-pandas.core.indexes.timedeltas] -ignore_errors=True - -[mypy-pandas.core.indexing] -ignore_errors=True - -[mypy-pandas.core.internals.blocks] -ignore_errors=True - -[mypy-pandas.core.panel] -ignore_errors=True - -[mypy-pandas.core.reshape.merge] -ignore_errors=True - -[mypy-pandas.core.reshape.reshape] -ignore_errors=True - -[mypy-pandas.core.series] -ignore_errors=True - -[mypy-pandas.core.util.hashing] -ignore_errors=True - -[mypy-pandas.core.window] -ignore_errors=True - -[mypy-pandas.io.pytables] -ignore_errors=True - -[mypy-pandas.util._doctools] -ignore_errors=True - -[mypy-pandas.util.testing] -ignore_errors=True +ignore_errors=True \ No newline at end of file diff --git a/pandas/core/base.py b/pandas/core/base.py index 5bccaeef66a82..301af59eadb0e 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -1572,5 +1572,5 @@ def duplicated(self, keep='first'): # ---------------------------------------------------------------------- # abstracts - def _update_inplace(self, result, **kwargs): + def _update_inplace(self, result, verify_is_copy=True, **kwargs): raise AbstractMethodError(self) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 4999153207395..b009178c7a767 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -6,7 +6,7 @@ import operator import pickle from textwrap import dedent -from typing import FrozenSet, List, Set +from typing import Callable, FrozenSet, List, Set import warnings import weakref @@ -3680,7 +3680,7 @@ class animal locomotion result._set_is_copy(self, copy=not result._is_view) return result - _xs = xs + _xs = xs # type: Callable def select(self, crit, axis=0): """ diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 65123a8f0f5a7..eb210224f6ec3 100755 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -88,8 +88,8 @@ class IndexingError(Exception): class _NDFrameIndexer(_NDFrameIndexerBase): - _valid_types = None - _exception = KeyError + _valid_types = None # type: str + _exception = Exception axis = None def __call__(self, axis=None): diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 0c49ebb55acdd..f98ab89a9aa23 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -7,7 +7,8 @@ import numpy as np -from pandas._libs import internals as libinternals, lib, tslib, tslibs +from pandas._libs import lib, tslib, tslibs +import pandas._libs.internals as libinternals from pandas._libs.tslibs import Timedelta, conversion, is_null_datetimelike from pandas.util._validators import validate_bool_kwarg @@ -2050,12 +2051,15 @@ def get_values(self, dtype=None): class DatetimeBlock(DatetimeLikeBlockMixin, Block): __slots__ = () is_datetime = True - _can_hold_na = True def __init__(self, values, placement, ndim=None): values = self._maybe_coerce_values(values) super().__init__(values, placement=placement, ndim=ndim) + @property + def _can_hold_na(self): + return True + def _maybe_coerce_values(self, values): """Input validation for values passed to __init__. Ensure that we have datetime64ns, coercing if necessary. diff --git a/pandas/core/reshape/merge.py b/pandas/core/reshape/merge.py index c21af1c7e820d..1a80b35629356 100644 --- a/pandas/core/reshape/merge.py +++ b/pandas/core/reshape/merge.py @@ -8,7 +8,8 @@ import numpy as np -from pandas._libs import hashtable as libhashtable, join as libjoin, lib +from pandas._libs import hashtable as libhashtable, lib +import pandas._libs.join as libjoin from pandas.errors import MergeError from pandas.util._decorators import Appender, Substitution diff --git a/pandas/core/reshape/reshape.py b/pandas/core/reshape/reshape.py index bd695e2d0d83d..c59f9ffc48055 100644 --- a/pandas/core/reshape/reshape.py +++ b/pandas/core/reshape/reshape.py @@ -3,7 +3,8 @@ import numpy as np -from pandas._libs import algos as _algos, reshape as _reshape +import pandas._libs.algos as _algos +import pandas._libs.reshape as _reshape from pandas._libs.sparse import IntIndex from pandas.core.dtypes.cast import maybe_promote diff --git a/pandas/core/util/hashing.py b/pandas/core/util/hashing.py index 29fc1e3671a83..93074f5afa2b3 100644 --- a/pandas/core/util/hashing.py +++ b/pandas/core/util/hashing.py @@ -5,7 +5,8 @@ import numpy as np -from pandas._libs import hashing, tslibs +import pandas._libs.hashing as hashing +import pandas._libs.tslibs as tslibs from pandas.core.dtypes.cast import infer_dtype_from_scalar from pandas.core.dtypes.common import ( diff --git a/pandas/core/window.py b/pandas/core/window.py index 2d7fdbeffbccc..9ec1902cb4937 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -5,6 +5,7 @@ from collections import defaultdict from datetime import timedelta from textwrap import dedent +from typing import Set import warnings import numpy as np @@ -42,7 +43,7 @@ class _Window(PandasObject, SelectionMixin): _attributes = ['window', 'min_periods', 'center', 'win_type', 'axis', 'on', 'closed'] - exclusions = set() + exclusions = set() # type: Set[str] def __init__(self, obj, window=None, min_periods=None, center=False, win_type=None, axis=0, on=None, closed=None, @@ -305,10 +306,10 @@ def _center_window(self, result, window): result = np.copy(result[tuple(lead_indexer)]) return result - def aggregate(self, arg, *args, **kwargs): - result, how = self._aggregate(arg, *args, **kwargs) + def aggregate(self, func, *args, **kwargs): + result, how = self._aggregate(func, *args, **kwargs) if result is None: - return self.apply(arg, raw=False, args=args, kwargs=kwargs) + return self.apply(func, raw=False, args=args, kwargs=kwargs) return result agg = aggregate @@ -788,7 +789,7 @@ def __init__(self, obj, *args, **kwargs): corr = GroupByMixin._dispatch('corr', other=None, pairwise=None) cov = GroupByMixin._dispatch('cov', other=None, pairwise=None) - def _apply(self, func, name, window=None, center=None, + def _apply(self, func, name=None, window=None, center=None, check_minp=None, **kwargs): """ Dispatch to apply; we are stripping all of the _apply kwargs and diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index b0a00f25c538d..3194804b4efc2 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -10,6 +10,7 @@ import os import re import time +from typing import List, Optional, Type, Union import warnings import numpy as np @@ -2297,9 +2298,9 @@ class Fixed(StringMixin): parent : my parent HDFStore group : the group node where the table resides """ - pandas_kind = None - obj_type = None - ndim = None + pandas_kind = None # type: str + obj_type = None # type: Type[Union[DataFrame, Series]] + ndim = None # type: int is_table = False def __init__(self, parent, group, encoding=None, errors='strict', @@ -2459,7 +2460,7 @@ class GenericFixed(Fixed): """ a generified fixed version """ _index_type_map = {DatetimeIndex: 'datetime', PeriodIndex: 'period'} _reverse_index_map = {v: k for k, v in _index_type_map.items()} - attributes = [] + attributes = [] # type: List[str] # indexer helpders def _class_to_alias(self, cls): @@ -3052,7 +3053,7 @@ class Table(Fixed): """ pandas_kind = 'wide_table' - table_type = None + table_type = None # type: str levels = 1 is_table = True is_shape_reversed = False @@ -3873,7 +3874,7 @@ class LegacyTable(Table): IndexCol(name='index', axis=1, pos=0), IndexCol(name='column', axis=2, pos=1, index_kind='columns_kind'), DataCol(name='fields', cname='values', kind_attr='fields', pos=2) - ] + ] # type: Optional[List[IndexCol]] table_type = 'legacy' ndim = 3 @@ -4126,7 +4127,7 @@ class AppendableFrameTable(AppendableTable): pandas_kind = 'frame_table' table_type = 'appendable_frame' ndim = 2 - obj_type = DataFrame + obj_type = DataFrame # type: Type[Union[DataFrame, Series]] @property def is_transposed(self): diff --git a/pandas/util/testing.py b/pandas/util/testing.py index 9084ebc736599..da92540e2b86f 100644 --- a/pandas/util/testing.py +++ b/pandas/util/testing.py @@ -21,7 +21,7 @@ from pandas._config.localization import ( # noqa:F401 can_set_locale, get_locales, set_locale) -from pandas._libs import testing as _testing +import pandas._libs.testing as _testing from pandas.compat import raise_with_traceback from pandas.core.dtypes.common import (