id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
173,280
from __future__ import annotations from datetime import ( datetime, timedelta, ) from functools import wraps import operator from typing import ( TYPE_CHECKING, Any, Callable, Iterator, Literal, Sequence, TypeVar, Union, cast, final, overload, ) import warnings import...
null
173,281
from __future__ import annotations from datetime import ( datetime, timedelta, ) from functools import wraps import operator from typing import ( TYPE_CHECKING, Any, Callable, Iterator, Literal, Sequence, TypeVar, Union, cast, final, overload, ) import warnings import...
null
173,282
from __future__ import annotations from datetime import ( datetime, timedelta, ) from functools import wraps import operator from typing import ( TYPE_CHECKING, Any, Callable, Iterator, Literal, Sequence, TypeVar, Union, cast, final, overload, ) import warnings import...
If a `periods` argument is passed to the Datetime/Timedelta Array/Index constructor, cast it to an integer. Parameters ---------- periods : None, float, int Returns ------- periods : None or int Raises ------ TypeError if periods is None, float, or int
173,283
from __future__ import annotations from datetime import ( datetime, timedelta, ) from functools import wraps import operator from typing import ( TYPE_CHECKING, Any, Callable, Iterator, Literal, Sequence, TypeVar, Union, cast, final, overload, ) import warnings import...
If the user passes a freq and another freq is inferred from passed data, require that they match. Parameters ---------- freq : DateOffset or None inferred_freq : DateOffset or None freq_infer : bool Returns ------- freq : DateOffset or None freq_infer : bool Notes ----- We assume at this point that `maybe_infer_freq` h...
173,284
from __future__ import annotations from datetime import ( datetime, timedelta, ) from functools import wraps import operator from typing import ( TYPE_CHECKING, Any, Callable, Iterator, Literal, Sequence, TypeVar, Union, cast, final, overload, ) import warnings import...
Return the unit str corresponding to the dtype's resolution. Parameters ---------- dtype : DatetimeTZDtype or np.dtype If np.dtype, we assume it is a datetime64 dtype. Returns ------- str
173,285
from __future__ import annotations from copy import deepcopy import operator import re from typing import ( TYPE_CHECKING, Any, Callable, Literal, Sequence, TypeVar, cast, ) import numpy as np from pandas._libs import lib from pandas._typing import ( ArrayLike, AxisInt, Dtype, ...
null
173,286
from __future__ import annotations from copy import deepcopy import operator import re from typing import ( TYPE_CHECKING, Any, Callable, Literal, Sequence, TypeVar, cast, ) import numpy as np from pandas._libs import lib from pandas._typing import ( ArrayLike, AxisInt, Dtype, ...
null
173,287
from __future__ import annotations from copy import deepcopy import operator import re from typing import ( TYPE_CHECKING, Any, Callable, Literal, Sequence, TypeVar, cast, ) import numpy as np from pandas._libs import lib from pandas._typing import ( ArrayLike, AxisInt, Dtype, ...
null
173,288
from __future__ import annotations import warnings import numpy as np import pyarrow from pandas.errors import PerformanceWarning from pandas.util._exceptions import find_stack_level class PerformanceWarning(Warning): """ Warning raised when there is a possible performance impact. """ def find_stack_level...
Raise a PerformanceWarning for falling back to ExtensionArray's non-pyarrow method
173,289
from __future__ import annotations import warnings import numpy as np import pyarrow from pandas.errors import PerformanceWarning from pandas.util._exceptions import find_stack_level The provided code snippet includes necessary dependencies for implementing the `pyarrow_array_to_numpy_and_mask` function. Write a Pytho...
Convert a primitive pyarrow.Array to a numpy array and boolean mask based on the buffers of the Array. At the moment pyarrow.BooleanArray is not supported. Parameters ---------- arr : pyarrow.Array dtype : numpy.dtype Returns ------- (data, mask) Tuple of two numpy arrays with the raw data (with specified dtype) and a ...
173,290
from __future__ import annotations from datetime import timedelta import operator from typing import ( TYPE_CHECKING, Any, Callable, Literal, Sequence, TypeVar, overload, ) import numpy as np from pandas._libs import ( algos as libalgos, lib, ) from pandas._libs.arrays import NDArray...
null
173,291
from __future__ import annotations from datetime import timedelta import operator from typing import ( TYPE_CHECKING, Any, Callable, Literal, Sequence, TypeVar, overload, ) import numpy as np from pandas._libs import ( algos as libalgos, lib, ) from pandas._libs.arrays import NDArray...
Helper function to render a consistent error message when raising IncompatibleFrequency. Parameters ---------- left : PeriodArray right : None, DateOffset, Period, ndarray, or timedelta-like Returns ------- IncompatibleFrequency Exception to be raised by the caller.
173,292
from __future__ import annotations from datetime import timedelta import operator from typing import ( TYPE_CHECKING, Any, Callable, Literal, Sequence, TypeVar, overload, ) import numpy as np from pandas._libs import ( algos as libalgos, lib, ) from pandas._libs.arrays import NDArray...
Construct a new PeriodArray from a sequence of Period scalars. Parameters ---------- data : Sequence of Period objects A sequence of Period objects. These are required to all have the same ``freq.`` Missing values can be indicated by ``None`` or ``pandas.NaT``. freq : str, Tick, or Offset The frequency of every element...
173,293
from __future__ import annotations from datetime import timedelta import operator from typing import ( TYPE_CHECKING, Any, Callable, Literal, Sequence, TypeVar, overload, ) import numpy as np from pandas._libs import ( algos as libalgos, lib, ) from pandas._libs.arrays import NDArray...
null
173,294
from __future__ import annotations from datetime import timedelta import operator from typing import ( TYPE_CHECKING, Any, Callable, Literal, Sequence, TypeVar, overload, ) import numpy as np from pandas._libs import ( algos as libalgos, lib, ) from pandas._libs.arrays import NDArray...
null
173,295
from __future__ import annotations from datetime import timedelta import operator from typing import ( TYPE_CHECKING, Any, Callable, Literal, Sequence, TypeVar, overload, ) import numpy as np from pandas._libs import ( algos as libalgos, lib, ) from pandas._libs.arrays import NDArray...
If both a dtype and a freq are available, ensure they match. If only dtype is available, extract the implied freq. Parameters ---------- dtype : dtype freq : DateOffset or None Returns ------- freq : DateOffset Raises ------ ValueError : non-period dtype IncompatibleFrequency : mismatch between dtype and freq
173,296
from __future__ import annotations from datetime import timedelta import operator from typing import ( TYPE_CHECKING, Any, Callable, Literal, Sequence, TypeVar, overload, ) import numpy as np from pandas._libs import ( algos as libalgos, lib, ) from pandas._libs.arrays import NDArray...
Convert an datetime-like array to values Period ordinals. Parameters ---------- data : Union[Series[datetime64[ns]], DatetimeIndex, ndarray[datetime64ns]] freq : Optional[Union[str, Tick]] Must match the `freq` on the `data` if `data` is a DatetimeIndex or Series. tz : Optional[tzinfo] Returns ------- ordinals : ndarra...
173,297
from __future__ import annotations from datetime import timedelta import operator from typing import ( TYPE_CHECKING, Any, Callable, Literal, Sequence, TypeVar, overload, ) import numpy as np from pandas._libs import ( algos as libalgos, lib, ) from pandas._libs.arrays import NDArray...
null
173,298
from __future__ import annotations from datetime import timedelta import operator from typing import ( TYPE_CHECKING, Any, Callable, Literal, Sequence, TypeVar, overload, ) import numpy as np from pandas._libs import ( algos as libalgos, lib, ) from pandas._libs.arrays import NDArray...
null
173,299
from __future__ import annotations import operator from operator import ( le, lt, ) import textwrap from typing import ( TYPE_CHECKING, Iterator, Literal, Sequence, TypeVar, Union, cast, overload, ) import numpy as np from pandas._config import get_option from pandas._libs import...
Try to do platform conversion, with special casing for IntervalArray. Wrapper around maybe_convert_platform that alters the default return dtype in certain cases to be compatible with IntervalArray. For example, empty lists return with integer dtype instead of object dtype, which is prohibited for IntervalArray. Parame...
173,300
from __future__ import annotations from datetime import timedelta import operator from typing import ( TYPE_CHECKING, Iterator, cast, ) import warnings import numpy as np from pandas._libs import ( lib, tslibs, ) from pandas._libs.tslibs import ( BaseOffset, NaT, NaTType, Tick, T...
null
173,301
from __future__ import annotations from datetime import timedelta import operator from typing import ( TYPE_CHECKING, Iterator, cast, ) import warnings import numpy as np from pandas._libs import ( lib, tslibs, ) from pandas._libs.tslibs import ( BaseOffset, NaT, NaTType, Tick, T...
null
173,302
from __future__ import annotations import re from typing import ( Callable, Union, ) import numpy as np from pandas._libs import ( lib, missing as libmissing, ) from pandas._typing import ( Dtype, Scalar, npt, ) from pandas.compat import pa_version_under7p0 from pandas.core.dtypes.common imp...
null
173,303
from __future__ import annotations from functools import wraps from typing import ( TYPE_CHECKING, Any, Literal, Sequence, TypeVar, cast, overload, ) import numpy as np from pandas._libs import lib from pandas._libs.arrays import NDArrayBacked from pandas._typing import ( ArrayLike, ...
Decorator to ravel a 2D array before passing it to a cython operation, then reshape the result to our own shape.
173,304
from __future__ import annotations from datetime import ( datetime, time, timedelta, tzinfo, ) from typing import ( TYPE_CHECKING, Iterator, cast, ) import warnings import numpy as np from pandas._libs import ( lib, tslib, ) from pandas._libs.tslibs import ( BaseOffset, NaT, ...
null
173,305
from __future__ import annotations from datetime import ( datetime, time, timedelta, tzinfo, ) from typing import ( TYPE_CHECKING, Iterator, cast, ) import warnings import numpy as np from pandas._libs import ( lib, tslib, ) from pandas._libs.tslibs import ( BaseOffset, NaT, ...
Parameters ---------- data : list-like copy : bool, default False tz : tzinfo or None, default None dayfirst : bool, default False yearfirst : bool, default False ambiguous : str, bool, or arraylike, default 'raise' See pandas._libs.tslibs.tzconversion.tz_localize_to_utc. out_unit : str or None, default None Desired ou...
173,306
from __future__ import annotations from datetime import ( datetime, time, timedelta, tzinfo, ) from typing import ( TYPE_CHECKING, Iterator, cast, ) import warnings import numpy as np from pandas._libs import ( lib, tslib, ) from pandas._libs.tslibs import ( BaseOffset, NaT, ...
Check that a dtype, if passed, represents either a numpy datetime64[ns] dtype or a pandas DatetimeTZDtype. Parameters ---------- dtype : object Returns ------- dtype : None, numpy.dtype, or DatetimeTZDtype Raises ------ ValueError : invalid dtype Notes ----- Unlike _validate_tz_from_dtype, this does _not_ allow non-exi...
173,307
from __future__ import annotations from datetime import ( datetime, time, timedelta, tzinfo, ) from typing import ( TYPE_CHECKING, Iterator, cast, ) import warnings import numpy as np from pandas._libs import ( lib, tslib, ) from pandas._libs.tslibs import ( BaseOffset, NaT, ...
If the given dtype is a DatetimeTZDtype, extract the implied tzinfo object from it and check that it does not conflict with the given tz. Parameters ---------- dtype : dtype, str tz : None, tzinfo explicit_tz_none : bool, default False Whether tz=None was passed explicitly, as opposed to lib.no_default. Returns -------...
173,308
from __future__ import annotations from datetime import ( datetime, time, timedelta, tzinfo, ) from typing import ( TYPE_CHECKING, Iterator, cast, ) import warnings import numpy as np from pandas._libs import ( lib, tslib, ) from pandas._libs.tslibs import ( BaseOffset, NaT, ...
If a timezone is not explicitly given via `tz`, see if one can be inferred from the `start` and `end` endpoints. If more than one of these inputs provides a timezone, require that they all agree. Parameters ---------- start : Timestamp end : Timestamp tz : tzinfo or None Returns ------- tz : tzinfo or None Raises -----...
173,309
from __future__ import annotations from datetime import ( datetime, time, timedelta, tzinfo, ) from typing import ( TYPE_CHECKING, Iterator, cast, ) import warnings import numpy as np from pandas._libs import ( lib, tslib, ) from pandas._libs.tslibs import ( BaseOffset, NaT, ...
null
173,310
from __future__ import annotations from datetime import ( datetime, time, timedelta, tzinfo, ) from typing import ( TYPE_CHECKING, Iterator, cast, ) import warnings import numpy as np from pandas._libs import ( lib, tslib, ) from pandas._libs.tslibs import ( BaseOffset, NaT, ...
Localize a start or end Timestamp to the timezone of the corresponding start or end Timestamp Parameters ---------- ts : start or end Timestamp to potentially localize is_none : argument that should be None is_not_none : argument that should not be None freq : Tick, DateOffset, or None tz : str, timezone object or None...
173,311
from __future__ import annotations from collections import abc import numbers import operator from typing import ( TYPE_CHECKING, Any, Callable, Literal, Sequence, TypeVar, cast, overload, ) import warnings import numpy as np from pandas._libs import lib import pandas._libs.sparse as spl...
Perform a binary operation between two arrays. Parameters ---------- left : Union[SparseArray, ndarray] right : Union[SparseArray, ndarray] op : Callable The binary operation to perform name str Name of the callable. Returns ------- SparseArray
173,312
from __future__ import annotations from collections import abc import numbers import operator from typing import ( TYPE_CHECKING, Any, Callable, Literal, Sequence, TypeVar, cast, overload, ) import warnings import numpy as np from pandas._libs import lib import pandas._libs.sparse as spl...
Convert ndarray to sparse format Parameters ---------- arr : ndarray kind : {'block', 'integer'} fill_value : NaN or another value dtype : np.dtype, optional copy : bool, default False Returns ------- (sparse_values, index, fill_value) : (ndarray, SparseIndex, Scalar)
173,313
from __future__ import annotations from typing import ( TYPE_CHECKING, Iterable, ) import numpy as np from pandas._libs import lib from pandas._typing import ( IndexLabel, npt, ) from pandas.core.dtypes.missing import notna from pandas.core.algorithms import factorize from pandas.core.indexes.api import...
Convert a sparse Series to a scipy.sparse.coo_matrix using index levels row_levels, column_levels as the row and column labels respectively. Returns the sparse_matrix, row and column labels.
173,314
from __future__ import annotations from typing import ( TYPE_CHECKING, Iterable, ) import numpy as np from pandas._libs import lib from pandas._typing import ( IndexLabel, npt, ) from pandas.core.dtypes.missing import notna from pandas.core.algorithms import factorize from pandas.core.indexes.api import...
Convert a scipy.sparse.coo_matrix to a Series with type sparse. Parameters ---------- A : scipy.sparse.coo_matrix dense_index : bool, default False Returns ------- Series Raises ------ TypeError if A is not a coo_matrix
173,315
from __future__ import annotations import numbers from typing import ( TYPE_CHECKING, Any, Callable, Mapping, TypeVar, ) import numpy as np from pandas._libs import ( lib, missing as libmissing, ) from pandas._typing import ( Dtype, DtypeObj, npt, ) from pandas.errors import Abst...
null
173,316
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
null
173,317
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
null
173,318
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
Return the missing value for `values`. Parameters ---------- values : ndarray axis : int or None axis for the reduction, required if values.ndim > 1. Returns ------- result : scalar or ndarray For 1-D values, returns a scalar of the correct missing type. For 2-D values, returns a 1-D array where each element is missing...
173,319
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
NumPy operations on C-contiguous ndarrays with axis=1 can be very slow if axis 1 >> axis 0. Operate row-by-row and concatenate the results.
173,320
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
Check if any elements along an axis evaluate to True. Parameters ---------- values : ndarray axis : int, optional skipna : bool, default True mask : ndarray[bool], optional nan-mask if known Returns ------- result : bool Examples -------- >>> from pandas.core import nanops >>> s = pd.Series([1, 2]) >>> nanops.nanany(s)...
173,321
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
Check if all elements along an axis evaluate to True. Parameters ---------- values : ndarray axis : int, optional skipna : bool, default True mask : ndarray[bool], optional nan-mask if known Returns ------- result : bool Examples -------- >>> from pandas.core import nanops >>> s = pd.Series([1, 2, np.nan]) >>> nanops.n...
173,322
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
Sum the elements along an axis ignoring NaNs Parameters ---------- values : ndarray[dtype] axis : int, optional skipna : bool, default True min_count: int, default 0 mask : ndarray[bool], optional nan-mask if known Returns ------- result : dtype Examples -------- >>> from pandas.core import nanops >>> s = pd.Series([1,...
173,323
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
Compute the mean of the element along an axis ignoring NaNs Parameters ---------- values : ndarray axis : int, optional skipna : bool, default True mask : ndarray[bool], optional nan-mask if known Returns ------- float Unless input is a float array, in which case use the same precision as the input array. Examples ----...
173,324
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
Parameters ---------- values : ndarray axis : int, optional skipna : bool, default True mask : ndarray[bool], optional nan-mask if known Returns ------- result : float Unless input is a float array, in which case use the same precision as the input array. Examples -------- >>> from pandas.core import nanops >>> s = pd....
173,325
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
Compute the standard deviation along given axis while ignoring NaNs Parameters ---------- values : ndarray axis : int, optional skipna : bool, default True ddof : int, default 1 Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements. mask : ndarray[bool], optio...
173,326
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
Compute the standard error in the mean along given axis while ignoring NaNs Parameters ---------- values : ndarray axis : int, optional skipna : bool, default True ddof : int, default 1 Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements. mask : ndarray[bool...
173,327
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
null
173,328
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
Parameters ---------- values : ndarray axis : int, optional skipna : bool, default True mask : ndarray[bool], optional nan-mask if known Returns ------- result : int or ndarray[int] The index/indices of max value in specified axis or -1 in the NA case Examples -------- >>> from pandas.core import nanops >>> arr = np.ar...
173,329
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
Parameters ---------- values : ndarray axis : int, optional skipna : bool, default True mask : ndarray[bool], optional nan-mask if known Returns ------- result : int or ndarray[int] The index/indices of min value in specified axis or -1 in the NA case Examples -------- >>> from pandas.core import nanops >>> arr = np.ar...
173,330
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
Compute the sample skewness. The statistic computed here is the adjusted Fisher-Pearson standardized moment coefficient G1. The algorithm computes this coefficient directly from the second and third central moment. Parameters ---------- values : ndarray axis : int, optional skipna : bool, default True mask : ndarray[bo...
173,331
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
Compute the sample excess kurtosis The statistic computed here is the adjusted Fisher-Pearson standardized moment coefficient G2, computed directly from the second and fourth central moment. Parameters ---------- values : ndarray axis : int, optional skipna : bool, default True mask : ndarray[bool], optional nan-mask i...
173,332
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
Parameters ---------- values : ndarray[dtype] axis : int, optional skipna : bool, default True min_count: int, default 0 mask : ndarray[bool], optional nan-mask if known Returns ------- Dtype The product of all elements on a given axis. ( NaNs are treated as 1) Examples -------- >>> from pandas.core import nanops >>> s...
173,333
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
a, b: ndarrays
173,334
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
null
173,335
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
null
173,336
from __future__ import annotations import functools import itertools import operator from typing import ( Any, Callable, cast, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import ( NaT, NaTType, iNaT, lib, ) from pandas._typing import ( Arr...
Cumulative function with skipna support. Parameters ---------- values : np.ndarray or ExtensionArray accum_func : {np.cumprod, np.maximum.accumulate, np.cumsum, np.minimum.accumulate} skipna : bool Returns ------- np.ndarray or ExtensionArray
173,337
from __future__ import annotations import numba import numpy as np from pandas.core._numba.kernels.shared import is_monotonic_increasing def add_sum( val: float, nobs: int, sum_x: float, compensation: float, num_consecutive_same_value: int, prev_value: float, ) -> tuple[int, float, float, int, f...
null
173,338
from __future__ import annotations import numba import numpy as np from pandas.core._numba.kernels.shared import is_monotonic_increasing def add_mean( val: float, nobs: int, sum_x: float, neg_ct: int, compensation: float, num_consecutive_same_value: int, prev_value: float, ) -> tuple[int, fl...
null
173,339
from __future__ import annotations import numba import numpy as np from pandas.core._numba.kernels.shared import is_monotonic_increasing def add_var( val: float, nobs: int, mean_x: float, ssqdm_x: float, compensation: float, num_consecutive_same_value: int, prev_value: float, ) -> tuple[int,...
null
173,340
from __future__ import annotations import numba import numpy as np def sliding_min_max( values: np.ndarray, start: np.ndarray, end: np.ndarray, min_periods: int, is_max: bool, ) -> np.ndarray: N = len(start) nobs = 0 output = np.empty(N, dtype=np.float64) # Use deque once numba supp...
null
173,341
from __future__ import annotations import functools from typing import ( TYPE_CHECKING, Callable, ) import numpy as np from pandas._typing import Scalar from pandas.compat._optional import import_optional_dependency TYPE_CHECKING = True class Callable(BaseTypingInstance): def py__call__(self, arguments): ...
Generate a Numba function that loops over the columns 2D object and applies a 1D numba kernel over each column. Parameters ---------- func : function aggregation function to be applied to each column nopython : bool nopython to be passed into numba.jit nogil : bool nogil to be passed into numba.jit parallel : bool para...
173,342
from __future__ import annotations import operator from typing import Any import numpy as np from pandas._libs import lib from pandas._libs.ops_dispatch import maybe_dispatch_ufunc_to_dunder_op from pandas.core.dtypes.generic import ABCNDFrame from pandas.core import roperator from pandas.core.construction import extra...
Compatibility with numpy ufuncs. See also -------- numpy.org/doc/stable/reference/arrays.classes.html#numpy.class.__array_ufunc__
173,343
from __future__ import annotations from typing import ( TYPE_CHECKING, Any, ) import numpy as np from pandas._typing import AnyArrayLike from pandas.core.dtypes.common import ( is_array_like, is_bool_dtype, is_extension_array_dtype, is_integer, is_integer_dtype, is_list_like, ) from pand...
Check if a slice object can be interpreted as a positional indexer. Parameters ---------- slc : slice Returns ------- bool Notes ----- A valid positional slice may also be interpreted as a label-based slice depending on the index being sliced.
173,344
from __future__ import annotations from typing import ( TYPE_CHECKING, Any, ) import numpy as np from pandas._typing import AnyArrayLike from pandas.core.dtypes.common import ( is_array_like, is_bool_dtype, is_extension_array_dtype, is_integer, is_integer_dtype, is_list_like, ) from pand...
Return True if we are all scalar indexers. Parameters ---------- indexer : object ndim : int Number of dimensions in the object being indexed. Returns ------- bool
173,345
from __future__ import annotations from typing import ( TYPE_CHECKING, Any, ) import numpy as np from pandas._typing import AnyArrayLike from pandas.core.dtypes.common import ( is_array_like, is_bool_dtype, is_extension_array_dtype, is_integer, is_integer_dtype, is_list_like, ) from pand...
Check if we have an empty indexer. Parameters ---------- indexer : object Returns ------- bool
173,346
from __future__ import annotations from typing import ( TYPE_CHECKING, Any, ) import numpy as np from pandas._typing import AnyArrayLike from pandas.core.dtypes.common import ( is_array_like, is_bool_dtype, is_extension_array_dtype, is_integer, is_integer_dtype, is_list_like, ) from pand...
Validate that value and indexer are the same length. An special-case is allowed for when the indexer is a boolean array and the number of true values equals the length of ``value``. In this case, no exception is raised. Parameters ---------- indexer : sequence Key for the setitem. value : array-like Value for the setit...
173,347
from __future__ import annotations from typing import ( TYPE_CHECKING, Any, ) import numpy as np from pandas._typing import AnyArrayLike from pandas.core.dtypes.common import ( is_array_like, is_bool_dtype, is_extension_array_dtype, is_integer, is_integer_dtype, is_list_like, ) from pand...
Perform bounds-checking for an indexer. -1 is allowed for indicating missing values. Parameters ---------- indices : ndarray n : int Length of the array being indexed. Raises ------ ValueError Examples -------- >>> validate_indices(np.array([1, 2]), 3) # OK >>> validate_indices(np.array([1, -2]), 3) Traceback (most rec...
173,348
from __future__ import annotations from typing import ( TYPE_CHECKING, Any, ) import numpy as np from pandas._typing import AnyArrayLike from pandas.core.dtypes.common import ( is_array_like, is_bool_dtype, is_extension_array_dtype, is_integer, is_integer_dtype, is_list_like, ) from pand...
Attempt to convert indices into valid, positive indices. If we have negative indices, translate to positive here. If we have indices that are out-of-bounds, raise an IndexError. Parameters ---------- indices : array-like Array of indices that we are to convert. n : int Number of elements in the array that we are indexi...
173,349
from __future__ import annotations from typing import ( TYPE_CHECKING, Any, ) import numpy as np from pandas._typing import AnyArrayLike from pandas.core.dtypes.common import ( is_array_like, is_bool_dtype, is_extension_array_dtype, is_integer, is_integer_dtype, is_list_like, ) from pand...
Helper function to disallow multi-dimensional indexing on 1D Series/Index. GH#27125 indexer like idx[:, None] expands dim, but we cannot do that and keep an index, so we used to return ndarray, which was deprecated in GH#30588.
173,350
from __future__ import annotations from typing import ( TYPE_CHECKING, Any, ) import numpy as np from pandas._typing import AnyArrayLike from pandas.core.dtypes.common import ( is_array_like, is_bool_dtype, is_extension_array_dtype, is_integer, is_integer_dtype, is_list_like, ) from pand...
If we have a length-1 tuple/list that contains a slice, unpack to just the slice. Notes ----- The list case is deprecated.
173,351
from __future__ import annotations from typing import ( TYPE_CHECKING, Any, ) import numpy as np from pandas._typing import AnyArrayLike from pandas.core.dtypes.common import ( is_array_like, is_bool_dtype, is_extension_array_dtype, is_integer, is_integer_dtype, is_list_like, ) from pand...
Checks if a key used as indexer has the same length as the columns it is associated with. Parameters ---------- columns : Index The columns of the DataFrame to index. key : A list-like of keys to index with. value : DataFrame The value to set for the keys. Raises ------ ValueError: If the length of key is not equal to ...
173,352
from __future__ import annotations from typing import ( TYPE_CHECKING, Any, ) import numpy as np from pandas._typing import AnyArrayLike from pandas.core.dtypes.common import ( is_array_like, is_bool_dtype, is_extension_array_dtype, is_integer, is_integer_dtype, is_list_like, ) from pand...
Possibly unpack arr[..., n] to arr[n]
173,353
from __future__ import annotations from typing import ( TYPE_CHECKING, Any, ) import numpy as np from pandas._typing import AnyArrayLike from pandas.core.dtypes.common import ( is_array_like, is_bool_dtype, is_extension_array_dtype, is_integer, is_integer_dtype, is_list_like, ) from pand...
Check if `indexer` is a valid array indexer for `array`. For a boolean mask, `array` and `indexer` are checked to have the same length. The dtype is validated, and if it is an integer or boolean ExtensionArray, it is checked if there are missing values present, and it is converted to the appropriate numpy array. Other ...
173,354
from __future__ import annotations import os from typing import Callable import pandas._config.config as cf from pandas._config.config import ( is_bool, is_callable, is_instance_factory, is_int, is_nonnegative_int, is_one_of_factory, is_str, is_text, ) with cf.config_prefix("compute"): ...
null
173,355
from __future__ import annotations import os from typing import Callable import pandas._config.config as cf from pandas._config.config import ( is_bool, is_callable, is_instance_factory, is_int, is_nonnegative_int, is_one_of_factory, is_str, is_text, ) with cf.config_prefix("compute"): ...
null
173,356
from __future__ import annotations import os from typing import Callable import pandas._config.config as cf from pandas._config.config import ( is_bool, is_callable, is_instance_factory, is_int, is_nonnegative_int, is_one_of_factory, is_str, is_text, ) with cf.config_prefix("compute"): ...
null
173,357
from __future__ import annotations import os from typing import Callable import pandas._config.config as cf from pandas._config.config import ( is_bool, is_callable, is_instance_factory, is_int, is_nonnegative_int, is_one_of_factory, is_str, is_text, ) with cf.config_prefix("compute"): ...
null
173,358
from __future__ import annotations import os from typing import Callable import pandas._config.config as cf from pandas._config.config import ( is_bool, is_callable, is_instance_factory, is_int, is_nonnegative_int, is_one_of_factory, is_str, is_text, ) The provided code snippet includes...
Detect if Python is running in a terminal. Returns True if Python is running in a terminal or False if not.
173,359
from __future__ import annotations import os from typing import Callable import pandas._config.config as cf from pandas._config.config import ( is_bool, is_callable, is_instance_factory, is_int, is_nonnegative_int, is_one_of_factory, is_str, is_text, ) def _use_inf_as_na(key) -> None: ...
null
173,360
from __future__ import annotations import os from typing import Callable import pandas._config.config as cf from pandas._config.config import ( is_bool, is_callable, is_instance_factory, is_int, is_nonnegative_int, is_one_of_factory, is_str, is_text, ) def _get_plot_backend(backend: str...
null
173,361
from __future__ import annotations import os from typing import Callable import pandas._config.config as cf from pandas._config.config import ( is_bool, is_callable, is_instance_factory, is_int, is_nonnegative_int, is_one_of_factory, is_str, is_text, ) with cf.config_prefix("compute"): ...
null
173,362
from __future__ import annotations from datetime import ( datetime, time, ) import numpy as np from pandas._libs.lib import is_list_like from pandas._typing import DateTimeErrorChoices from pandas.core.dtypes.generic import ( ABCIndex, ABCSeries, ) from pandas.core.dtypes.missing import notna _time_form...
Parse time strings to time objects using fixed strptime formats ("%H:%M", "%H%M", "%I:%M%p", "%I%M%p", "%H:%M:%S", "%H%M%S", "%I:%M:%S%p", "%I%M%S%p") Use infer_time_format if all the strings are in the same format to speed up conversion. Parameters ---------- arg : string in time format, datetime.time, list, tuple, 1-...
173,363
from __future__ import annotations from datetime import timedelta from typing import ( TYPE_CHECKING, overload, ) import numpy as np from pandas._libs import lib from pandas._libs.tslibs import ( NaT, NaTType, ) from pandas._libs.tslibs.timedeltas import ( Timedelta, parse_timedelta_unit, ) from...
null
173,364
from __future__ import annotations from datetime import timedelta from typing import ( TYPE_CHECKING, overload, ) import numpy as np from pandas._libs import lib from pandas._libs.tslibs import ( NaT, NaTType, ) from pandas._libs.tslibs.timedeltas import ( Timedelta, parse_timedelta_unit, ) from...
null
173,365
from __future__ import annotations from datetime import timedelta from typing import ( TYPE_CHECKING, overload, ) import numpy as np from pandas._libs import lib from pandas._libs.tslibs import ( NaT, NaTType, ) from pandas._libs.tslibs.timedeltas import ( Timedelta, parse_timedelta_unit, ) from...
null
173,366
from __future__ import annotations from datetime import timedelta from typing import ( TYPE_CHECKING, overload, ) import numpy as np from pandas._libs import lib from pandas._libs.tslibs import ( NaT, NaTType, ) from pandas._libs.tslibs.timedeltas import ( Timedelta, parse_timedelta_unit, ) from...
Convert argument to timedelta. Timedeltas are absolute differences in times, expressed in difference units (e.g. days, hours, minutes, seconds). This method converts an argument from a recognized timedelta format / value into a Timedelta type. Parameters ---------- arg : str, timedelta, list-like or Series The data to ...
173,367
from __future__ import annotations from collections import abc from datetime import datetime from functools import partial from itertools import islice from typing import ( TYPE_CHECKING, Callable, Hashable, List, Tuple, TypedDict, Union, cast, overload, ) import warnings import nump...
try to parse the YYYYMMDD/%Y%m%d format, try to deal with NaT-like, arg is a passed in as an object dtype, but could really be ints/strings with nan-like/or floats (e.g. with nan) Parameters ---------- arg : np.ndarray[object] errors : {'raise','ignore','coerce'}
173,368
from __future__ import annotations import itertools from typing import ( TYPE_CHECKING, Hashable, Iterable, Iterator, cast, ) import numpy as np from pandas._libs import lib from pandas._libs.hashing import hash_object_array from pandas._typing import ( ArrayLike, npt, ) from pandas.core.dty...
Return a data hash of the Index/Series/DataFrame. Parameters ---------- obj : Index, Series, or DataFrame index : bool, default True Include the index in the hash (if Series/DataFrame). encoding : str, default 'utf8' Encoding for data & key when strings. hash_key : str, default _default_hash_key Hash_key for string key...
173,369
from __future__ import annotations import types from typing import ( TYPE_CHECKING, Callable, ) import numpy as np from pandas.compat._optional import import_optional_dependency from pandas.errors import NumbaUtilError GLOBAL_USE_NUMBA: bool = False The provided code snippet includes necessary dependencies for...
Signal whether to use numba routines.
173,370
from __future__ import annotations import types from typing import ( TYPE_CHECKING, Callable, ) import numpy as np from pandas.compat._optional import import_optional_dependency from pandas.errors import NumbaUtilError class NumbaUtilError(Exception): """ Error raised for unsupported Numba engine routi...
Return arguments to pass to numba.JIT, falling back on pandas default JIT settings. Parameters ---------- engine_kwargs : dict, default None user passed keyword arguments for numba.JIT kwargs : dict, default None user passed keyword arguments to pass into the JITed function Returns ------- dict[str, bool] nopython, nog...
173,371
from __future__ import annotations import codecs from functools import wraps import re from typing import ( TYPE_CHECKING, Callable, Hashable, Literal, cast, ) import warnings import numpy as np from pandas._libs import lib from pandas._typing import ( AlignJoin, DtypeObj, F, Scalar,...
null
173,372
The provided code snippet includes necessary dependencies for implementing the `cat_safe` function. Write a Python function `def cat_safe(list_of_columns: list, sep: str)` to solve the following problem: Auxiliary function for :meth:`str.cat`. Same signature as cat_core, but handles TypeErrors in concatenation, which...
Auxiliary function for :meth:`str.cat`. Same signature as cat_core, but handles TypeErrors in concatenation, which happen if the arrays in list_of columns have the wrong dtypes or content. Parameters ---------- list_of_columns : list of numpy arrays List of arrays to be concatenated with sep; these arrays may not conta...
173,373
class Hashable(Protocol, metaclass=ABCMeta): # TODO: This is special, in that a subclass of a hashable class may not be hashable # (for example, list vs. object). It's not obvious how to represent this. This class # is currently mostly useless for static checking. def __hash__(self) -> int: ... d...
null
173,374
from __future__ import annotations import codecs from functools import wraps import re from typing import ( TYPE_CHECKING, Callable, Hashable, Literal, cast, ) import warnings import numpy as np from pandas._libs import lib from pandas._typing import ( AlignJoin, DtypeObj, F, Scalar,...
null
173,375
from __future__ import annotations from typing import ( Any, TypeVar, cast, overload, ) from numpy import ndarray from pandas._libs.lib import ( is_bool, is_integer, ) from pandas._typing import ( Axis, AxisInt, ) from pandas.errors import UnsupportedFunctionCall from pandas.util._valida...
If 'Series.argmin' is called via the 'numpy' library, the third parameter in its signature is 'out', which takes either an ndarray or 'None', so check if the 'skipna' parameter is either an instance of ndarray or is None, since 'skipna' itself should be a boolean
173,376
from __future__ import annotations from typing import ( Any, TypeVar, cast, overload, ) from numpy import ndarray from pandas._libs.lib import ( is_bool, is_integer, ) from pandas._typing import ( Axis, AxisInt, ) from pandas.errors import UnsupportedFunctionCall from pandas.util._valida...
If 'Series.argmax' is called via the 'numpy' library, the third parameter in its signature is 'out', which takes either an ndarray or 'None', so check if the 'skipna' parameter is either an instance of ndarray or is None, since 'skipna' itself should be a boolean
173,377
from __future__ import annotations from typing import ( Any, TypeVar, cast, overload, ) from numpy import ndarray from pandas._libs.lib import ( is_bool, is_integer, ) from pandas._typing import ( Axis, AxisInt, ) from pandas.errors import UnsupportedFunctionCall from pandas.util._valida...
If 'Categorical.argsort' is called via the 'numpy' library, the first parameter in its signature is 'axis', which takes either an integer or 'None', so check if the 'ascending' parameter has either integer type or is None, since 'ascending' itself should be a boolean
173,378
from __future__ import annotations from typing import ( Any, TypeVar, cast, overload, ) from numpy import ndarray from pandas._libs.lib import ( is_bool, is_integer, ) from pandas._typing import ( Axis, AxisInt, ) from pandas.errors import UnsupportedFunctionCall from pandas.util._valida...
null
173,379
from __future__ import annotations from typing import ( Any, TypeVar, cast, overload, ) from numpy import ndarray from pandas._libs.lib import ( is_bool, is_integer, ) from pandas._typing import ( Axis, AxisInt, ) from pandas.errors import UnsupportedFunctionCall from pandas.util._valida...
null