Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Period.freq GL08" \
-i "pandas.Period.ordinal GL08" \
-i "pandas.errors.IncompatibleFrequency SA01,SS06,EX01" \
-i "pandas.errors.InvalidVersion GL08" \
-i "pandas.api.extensions.ExtensionArray.value_counts EX01,RT03,SA01" \
-i "pandas.core.groupby.DataFrameGroupBy.plot PR02" \
-i "pandas.core.groupby.SeriesGroupBy.plot PR02" \
-i "pandas.core.resample.Resampler.quantile PR01,PR07" \
-i "pandas.api.typing.DataFrameGroupBy.plot PR02" \
-i "pandas.api.typing.SeriesGroupBy.plot PR02" \
-i "pandas.api.typing.Resampler.quantile PR01,PR07" \
-i "pandas.arrays.NumpyExtensionArray GL08" \
-i "pandas.tseries.offsets.BDay PR02,SA01" \
-i "pandas.tseries.offsets.BHalfYearBegin.is_on_offset GL08" \
-i "pandas.tseries.offsets.BHalfYearBegin.n GL08" \
Expand Down
4 changes: 2 additions & 2 deletions doc/source/reference/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
=======
GroupBy
=======
.. currentmodule:: pandas.core.groupby
.. currentmodule:: pandas.api.typing

:class:`pandas.api.typing.DataFrameGroupBy` and :class:`pandas.api.typing.SeriesGroupBy`
instances are returned by groupby calls :func:`pandas.DataFrame.groupby` and
Expand Down Expand Up @@ -40,7 +40,7 @@ Function application helper

NamedAgg

.. currentmodule:: pandas.core.groupby
.. currentmodule:: pandas.api.typing

Function application
--------------------
Expand Down
2 changes: 1 addition & 1 deletion doc/source/reference/resampling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
==========
Resampling
==========
.. currentmodule:: pandas.core.resample
.. currentmodule:: pandas.api.typing

:class:`pandas.api.typing.Resampler` instances are returned by
resample calls: :func:`pandas.DataFrame.resample`, :func:`pandas.Series.resample`.
Expand Down
11 changes: 7 additions & 4 deletions doc/source/reference/window.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ calls: :func:`pandas.DataFrame.ewm` and :func:`pandas.Series.ewm`.

Rolling window functions
------------------------
.. currentmodule:: pandas.core.window.rolling
.. currentmodule:: pandas.api.typing

.. autosummary::
:toctree: api/
Expand Down Expand Up @@ -48,7 +48,8 @@ Rolling window functions

Weighted window functions
-------------------------
.. currentmodule:: pandas.core.window.rolling
.. currentmodule:: pandas.api.typing


.. autosummary::
:toctree: api/
Expand All @@ -62,7 +63,8 @@ Weighted window functions

Expanding window functions
--------------------------
.. currentmodule:: pandas.core.window.expanding
.. currentmodule:: pandas.api.typing


.. autosummary::
:toctree: api/
Expand Down Expand Up @@ -93,7 +95,8 @@ Expanding window functions

Exponentially-weighted window functions
---------------------------------------
.. currentmodule:: pandas.core.window.ewm
.. currentmodule:: pandas.api.typing


.. autosummary::
:toctree: api/
Expand Down
2 changes: 1 addition & 1 deletion doc/source/user_guide/enhancingperf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ by evaluate arithmetic and boolean expression all at once for large :class:`~pan
:func:`~pandas.eval` is many orders of magnitude slower for
smaller expressions or objects than plain Python. A good rule of thumb is
to only use :func:`~pandas.eval` when you have a
:class:`~pandas.core.frame.DataFrame` with more than 10,000 rows.
:class:`~pandas.DataFrame` with more than 10,000 rows.

Supported syntax
~~~~~~~~~~~~~~~~
Expand Down
3 changes: 3 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ versioneer = files('generate_version.py')

add_project_arguments('-DNPY_NO_DEPRECATED_API=0', language: 'c')
add_project_arguments('-DNPY_NO_DEPRECATED_API=0', language: 'cpp')
# Enables settings __module__ on cdef classes
# https://github.com/cython/cython/issues/7231
add_project_arguments('-DCYTHON_USE_TYPE_SPECS=1', language: 'c')

# Allow supporting older numpys than the version compiled against
# Set the define to the min supported version of numpy for pandas
Expand Down
4 changes: 4 additions & 0 deletions pandas/_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class OptionError(AttributeError, KeyError):
OptionError: No such option
"""

__module__ = "pandas.errors"


#
# User API
Expand Down Expand Up @@ -441,6 +443,8 @@ def __dir__(self) -> list[str]:


options = DictWrapper(_global_config)
# DictWrapper defines a custom setattr
object.__setattr__(options, "__module__", "pandas")

#
# Functions for use by pandas developers, in addition to User - api
Expand Down
2 changes: 2 additions & 0 deletions pandas/_libs/interval.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ cdef class Interval(IntervalMixin):
>>> year_2017.length
Timedelta('365 days 00:00:00')
"""
__module__ = "pandas"
_typ = "interval"
__array_priority__ = 1000

Expand Down Expand Up @@ -444,6 +445,7 @@ cdef class Interval(IntervalMixin):
>>> interval.closed
'left'
"""
__module__ = "pandas"

def __init__(self, left, right, str closed="right"):
# note: it is faster to just do these checks than to use a special
Expand Down
2 changes: 2 additions & 0 deletions pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2944,7 +2944,9 @@ class _NoDefault(Enum):

# Note: no_default is exported to the public API in pandas.api.extensions
no_default = _NoDefault.no_default # Sentinel indicating the default value.
no_default.__module__ = "pandas.api.extensions"
NoDefault = Literal[_NoDefault.no_default]
NoDefault.__module__ = "pandas.api.typing"


@cython.boundscheck(False)
Expand Down
3 changes: 2 additions & 1 deletion pandas/_libs/missing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ class NAType(C_NAType):
>>> True | pd.NA
True
"""
__module__ = "pandas"
__module__ = "pandas.api.typing"

_instance = None

Expand Down Expand Up @@ -546,3 +546,4 @@ class NAType(C_NAType):

C_NA = NAType() # C-visible
NA = C_NA # Python-visible
NA.__module__ = "pandas"
3 changes: 2 additions & 1 deletion pandas/_libs/tslibs/nattype.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class NaTType(_NaT):
1 NaT
"""

__module__ = "pandas"
__module__ = "pandas.api.typing"

def __new__(cls):
cdef _NaT base
Expand Down Expand Up @@ -1871,6 +1871,7 @@ default 'raise'

c_NaT = NaTType() # C-visible
NaT = c_NaT # Python-visible
NaT.__module__ = "pandas"


# ----------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions pandas/_libs/tslibs/np_datetime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ class OutOfBoundsDatetime(ValueError):
OutOfBoundsDatetime: Parsing "08335394550" to datetime overflows,
at position 0
"""
__module__ = "pandas.errors"
pass


Expand All @@ -212,6 +213,7 @@ class OutOfBoundsTimedelta(ValueError):
OutOfBoundsTimedelta: Cannot cast 139999 days 00:00:00
to unit='ns' without overflow.
"""
__module__ = "pandas.errors"
# Timedelta analogue to OutOfBoundsDatetime
pass

Expand Down
2 changes: 2 additions & 0 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,8 @@ class DateOffset(RelativeDeltaOffset, metaclass=OffsetMeta):
>>> ts + pd.DateOffset(hour=8)
Timestamp('2017-01-01 08:10:11')
"""
__module__ = "pandas"

def __setattr__(self, name, value):
raise AttributeError("DateOffset objects are immutable.")

Expand Down
1 change: 1 addition & 0 deletions pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,7 @@ class IncompatibleFrequency(TypeError):
Raised when trying to compare or operate between Periods with different
frequencies.
"""
__module__ = "pandas.errors"
pass


Expand Down
12 changes: 12 additions & 0 deletions pandas/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@


class SequenceNotStr(Protocol[_T_co]):
__module__: str = "pandas.api.typing.aliases"

@overload
def __getitem__(self, index: SupportsIndex, /) -> _T_co: ...

Expand Down Expand Up @@ -278,12 +280,16 @@ def tell(self) -> int:


class ReadBuffer(BaseBuffer, Protocol[AnyStr_co]):
__module__: str = "pandas.api.typing.aliases"

def read(self, n: int = ..., /) -> AnyStr_co:
# for BytesIOWrapper, gzip.GzipFile, bz2.BZ2File
...


class WriteBuffer(BaseBuffer, Protocol[AnyStr_contra]):
__module__: str = "pandas.api.typing.aliases"

def write(self, b: AnyStr_contra, /) -> Any:
# for gzip.GzipFile, bz2.BZ2File
...
Expand All @@ -294,14 +300,20 @@ def flush(self) -> Any:


class ReadPickleBuffer(ReadBuffer[bytes], Protocol):
__module__: str = "pandas.api.typing.aliases"

def readline(self) -> bytes: ...


class WriteExcelBuffer(WriteBuffer[bytes], Protocol):
__module__: str = "pandas.api.typing.aliases"

def truncate(self, size: int | None = ..., /) -> int: ...


class ReadCsvBuffer(ReadBuffer[AnyStr_co], Protocol):
__module__: str = "pandas.api.typing.aliases"

def __iter__(self) -> Iterator[AnyStr_co]:
# for engine=python
...
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class BaseExecutionEngine(abc.ABC):
simply runs the code with the Python interpreter and pandas.
"""

__module__ = "pandas.api.executors"

@staticmethod
@abc.abstractmethod
def map(
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/arrays/arrow/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ class ArrowExtensionArray(
Length: 3, dtype: int64[pyarrow]
""" # noqa: E501 (http link too long)

__module__ = "pandas.arrays"

_pa_array: pa.ChunkedArray
_dtype: ArrowDtype

Expand Down
6 changes: 5 additions & 1 deletion pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ class ExtensionArray:
https://github.com/pandas-dev/pandas/blob/main/pandas/tests/extension/list/array.py
"""

__module__ = "pandas.api.extensions"

# '_typ' is for pandas.core.dtypes.generic.ABCExtensionArray.
# Don't override this.
_typ = "extension"
Expand Down Expand Up @@ -1806,7 +1808,7 @@ def take(
.. code-block:: python

def take(self, indices, allow_fill=False, fill_value=None):
from pandas.core.algorithms import take
from pandas.api.extensions import take

# If the ExtensionArray is backed by an ndarray, then
# just pass that here instead of coercing to object.
Expand Down Expand Up @@ -2812,6 +2814,8 @@ class ExtensionScalarOpsMixin(ExtensionOpsMixin):
with NumPy arrays.
"""

__module__ = "pandas.api.extensions"

@classmethod
def _create_method(cls, op, coerce_to_dtype: bool = True, result_dtype=None):
"""
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/arrays/boolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ class BooleanArray(BaseMaskedArray):
Length: 3, dtype: boolean
"""

__module__ = "pandas.arrays"

_TRUE_VALUES = {"True", "TRUE", "true", "1", "1.0"}
_FALSE_VALUES = {"False", "FALSE", "false", "0", "0.0"}

Expand Down
2 changes: 2 additions & 0 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ class Categorical(NDArrayBackedExtensionArray, PandasObject, ObjectStringArrayMi
'c'
"""

__module__ = "pandas"

# For comparisons, so that numpy uses our implementation if the compare
# ops, which raise
__array_priority__ = 1000
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ class DatetimeArray(dtl.TimelikeOps, dtl.DatelikeOps):
Length: 2, dtype: datetime64[s]
"""

__module__ = "pandas.arrays"

_typ = "datetimearray"
_internal_fill_value = np.datetime64("NaT", "ns")
_recognized_scalars = (datetime, np.datetime64)
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/arrays/floating.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ class FloatingArray(NumericArray):
Length: 3, dtype: Float32
"""

__module__ = "pandas.arrays"

_dtype_cls = FloatingDtype


Expand Down
2 changes: 2 additions & 0 deletions pandas/core/arrays/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ class IntegerArray(NumericArray):
Length: 3, dtype: UInt16
"""

__module__ = "pandas.arrays"

_dtype_cls = IntegerDtype


Expand Down
2 changes: 2 additions & 0 deletions pandas/core/arrays/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ class IntervalArray(IntervalMixin, ExtensionArray):
:meth:`IntervalArray.from_breaks`, and :meth:`IntervalArray.from_tuples`.
"""

__module__ = "pandas.arrays"

can_hold_na = True
_na_value = _fill_value = np.nan

Expand Down
1 change: 1 addition & 0 deletions pandas/core/arrays/numpy_.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class NumpyExtensionArray(
NDArrayBackedExtensionArray,
ObjectStringArrayMixin,
):
__module__ = "pandas.arrays"
"""
A pandas ExtensionArray for NumPy data.

Expand Down
2 changes: 2 additions & 0 deletions pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ class PeriodArray(dtl.DatelikeOps, libperiod.PeriodMixin): # type: ignore[misc]
Length: 2, dtype: period[D]
"""

__module__ = "pandas.arrays"

# array priority higher than numpy scalars
__array_priority__ = 1000
_typ = "periodarray" # ABCPeriodArray
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/arrays/sparse/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ class SparseArray(OpsMixin, PandasObject, ExtensionArray):
Indices: array([2, 3], dtype=int32)
"""

__module__ = "pandas.arrays"

_subtyp = "sparse_array" # register ABCSparseArray
_hidden_attrs = PandasObject._hidden_attrs | frozenset([])
_sparse_index: SparseIndex
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/arrays/string_.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,8 @@ class StringArray(BaseStringArray, NumpyExtensionArray): # type: ignore[misc]
Length: 3, dtype: boolean
"""

__module__ = "pandas.arrays"

# undo the NumpyExtensionArray hack
_typ = "extension"

Expand Down
2 changes: 2 additions & 0 deletions pandas/core/arrays/string_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class ArrowStringArray(ObjectStringArrayMixin, ArrowExtensionArray, BaseStringAr
Length: 4, dtype: string
"""

__module__ = "pandas.arrays"

# error: Incompatible types in assignment (expression has type "StringDtype",
# base class "ArrowExtensionArray" defined the type as "ArrowDtype")
_dtype: StringDtype # type: ignore[assignment]
Expand Down
Loading
Loading