id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
173,180
from __future__ import annotations from datetime import datetime import functools from itertools import zip_longest import operator from typing import ( TYPE_CHECKING, Any, Callable, ClassVar, Hashable, Iterable, Literal, NoReturn, Sequence, TypeVar, cast, final, over...
When checking if our dtype is comparable with another, we need to unpack CategoricalDtype to look at its categories.dtype. Parameters ---------- other : Index Returns ------- Index
173,181
from __future__ import annotations from datetime import datetime import functools from itertools import zip_longest import operator from typing import ( TYPE_CHECKING, Any, Callable, ClassVar, Hashable, Iterable, Literal, NoReturn, Sequence, TypeVar, cast, final, over...
null
173,182
from __future__ import annotations import datetime as dt import operator from typing import ( TYPE_CHECKING, Hashable, ) import warnings import numpy as np import pytz from pandas._libs import ( NaT, Period, Timestamp, index as libindex, lib, ) from pandas._libs.tslibs import ( Resolutio...
This is called upon unpickling, rather than the default which doesn't have arguments and breaks __new__
173,183
from __future__ import annotations import datetime as dt import operator from typing import ( TYPE_CHECKING, Hashable, ) import warnings import numpy as np import pytz from pandas._libs import ( NaT, Period, Timestamp, index as libindex, lib, ) from pandas._libs.tslibs import ( Resolutio...
Return a fixed frequency DatetimeIndex with business day as the default. Parameters ---------- start : str or datetime-like, default None Left bound for generating dates. end : str or datetime-like, default None Right bound for generating dates. periods : int, default None Number of periods to generate. freq : str, Tim...
173,184
from __future__ import annotations import datetime as dt import operator from typing import ( TYPE_CHECKING, Hashable, ) import warnings import numpy as np import pytz from pandas._libs import ( NaT, Period, Timestamp, index as libindex, lib, ) from pandas._libs.tslibs import ( Resolutio...
null
173,185
from __future__ import annotations import numpy as np from pandas._typing import AxisInt AxisInt = int def shift(values: np.ndarray, periods: int, axis: AxisInt, fill_value) -> np.ndarray: new_values = values if periods == 0 or values.size == 0: return new_values.copy() # make sure array sent to...
null
173,186
from __future__ import annotations import functools from typing import ( TYPE_CHECKING, cast, overload, ) import numpy as np from pandas._libs import ( algos as libalgos, lib, ) from pandas._typing import ( ArrayLike, AxisInt, npt, ) from pandas.core.dtypes.cast import maybe_promote from...
Specialized version for 1D arrays. Differences compared to `take_nd`: - Assumes input array has already been converted to numpy array / EA - Assumes indexer is already guaranteed to be intp dtype ndarray - Only works for 1D arrays To ensure the lowest possible overhead. Note: similarly to `take_nd`, this function assum...
173,187
from __future__ import annotations import functools from typing import ( TYPE_CHECKING, cast, overload, ) import numpy as np from pandas._libs import ( algos as libalgos, lib, ) from pandas._typing import ( ArrayLike, AxisInt, npt, ) from pandas.core.dtypes.cast import maybe_promote from...
Specialized Cython take which sets NaN values in one pass.
173,188
from __future__ import annotations import functools from typing import ( TYPE_CHECKING, cast, overload, ) import numpy as np from pandas._libs import ( algos as libalgos, lib, ) from pandas._typing import ( ArrayLike, AxisInt, npt, ) from pandas.core.dtypes.cast import maybe_promote from...
null
173,189
from __future__ import annotations import operator import re from typing import ( Any, Pattern, ) import numpy as np from pandas._typing import ( ArrayLike, Scalar, npt, ) from pandas.core.dtypes.common import ( is_re, is_re_compilable, is_scalar, ) from pandas.core.dtypes.missing import...
Compare two array-like inputs of the same shape or two scalar values Calls operator.eq or re.search, depending on regex argument. If regex is True, perform an element-wise regex matching. Parameters ---------- a : array-like b : scalar or regex pattern regex : bool mask : np.ndarray[bool] Returns ------- mask : array-l...
173,190
from __future__ import annotations import operator import re from typing import ( Any, Pattern, ) import numpy as np from pandas._typing import ( ArrayLike, Scalar, npt, ) from pandas.core.dtypes.common import ( is_re, is_re_compilable, is_scalar, ) from pandas.core.dtypes.missing import...
Parameters ---------- values : ArrayLike Object dtype. rx : re.Pattern value : Any mask : np.ndarray[bool], optional Notes ----- Alters values in-place.
173,191
from __future__ import annotations from typing import Callable import numpy as np from pandas._libs import iNaT from pandas.core.dtypes.missing import isna def _cum_func( func: Callable, values: np.ndarray, *, skipna: bool = True, ): def cummin(values: np.ndarray, *, skipna: bool = True): return _c...
null
173,192
from __future__ import annotations from typing import Callable import numpy as np from pandas._libs import iNaT from pandas.core.dtypes.missing import isna def _cum_func( func: Callable, values: np.ndarray, *, skipna: bool = True, ): """ Accumulations for 1D datetimelike arrays. Parameters ...
null
173,193
from __future__ import annotations from typing import ( TYPE_CHECKING, Any, ) import numpy as np from pandas._libs import lib from pandas._typing import ( ArrayLike, npt, ) from pandas.compat import np_version_under1p21 from pandas.core.dtypes.cast import infer_dtype_from from pandas.core.dtypes.common ...
ExtensionArray-compatible implementation of np.putmask. The main difference is we do not handle repeating or truncating like numpy. Parameters ---------- values: np.ndarray or ExtensionArray mask : np.ndarray[bool] We assume extract_bool_array has already been called. value : Any
173,194
from __future__ import annotations from typing import ( TYPE_CHECKING, Any, ) import numpy as np from pandas._libs import lib from pandas._typing import ( ArrayLike, npt, ) from pandas.compat import np_version_under1p21 from pandas.core.dtypes.cast import infer_dtype_from from pandas.core.dtypes.common ...
np.putmask will truncate or repeat if `new` is a listlike with len(new) != len(values). We require an exact match. Parameters ---------- values : np.ndarray mask : np.ndarray[bool] new : Any
173,195
from __future__ import annotations from typing import ( TYPE_CHECKING, Any, ) import numpy as np from pandas._libs import lib from pandas._typing import ( ArrayLike, npt, ) from pandas.compat import np_version_under1p21 from pandas.core.dtypes.cast import infer_dtype_from from pandas.core.dtypes.common ...
Validate mask and check if this putmask operation is a no-op.
173,196
from __future__ import annotations import numpy as np from pandas._typing import ( ArrayLike, Scalar, npt, ) from pandas.compat.numpy import np_percentile_argname from pandas.core.dtypes.missing import ( isna, na_value_for_dtype, ) def quantile_with_mask( values: np.ndarray, mask: npt.NDArra...
Compute the quantiles of the given values for each quantile in `qs`. Parameters ---------- values : np.ndarray or ExtensionArray qs : np.ndarray[float64] interpolation : str Returns ------- np.ndarray or ExtensionArray
173,197
from __future__ import annotations from typing import Callable import numpy as np from pandas._typing import npt from pandas.core.dtypes.common import ( is_bool_dtype, is_float_dtype, is_integer_dtype, ) def _cum_func( func: Callable, values: np.ndarray, mask: npt.NDArray[np.bool_], *, s...
null
173,198
from __future__ import annotations from typing import Callable import numpy as np from pandas._typing import npt from pandas.core.dtypes.common import ( is_bool_dtype, is_float_dtype, is_integer_dtype, ) def _cum_func( func: Callable, values: np.ndarray, mask: npt.NDArray[np.bool_], *, s...
null
173,199
from __future__ import annotations from typing import Callable import numpy as np from pandas._libs import missing as libmissing from pandas._typing import ( AxisInt, npt, ) from pandas.core.nanops import check_below_min_count def _reductions( func: Callable, values: np.ndarray, mask: npt.NDArray[np...
null
173,200
from __future__ import annotations from typing import Callable import numpy as np from pandas._libs import missing as libmissing from pandas._typing import ( AxisInt, npt, ) from pandas.core.nanops import check_below_min_count def _reductions( func: Callable, values: np.ndarray, mask: npt.NDArray[np...
null
173,201
from __future__ import annotations from typing import Callable import numpy as np from pandas._libs import missing as libmissing from pandas._typing import ( AxisInt, npt, ) from pandas.core.nanops import check_below_min_count def _minmax( func: Callable, values: np.ndarray, mask: npt.NDArray[np.boo...
null
173,202
from __future__ import annotations from typing import Callable import numpy as np from pandas._libs import missing as libmissing from pandas._typing import ( AxisInt, npt, ) from pandas.core.nanops import check_below_min_count def _minmax( func: Callable, values: np.ndarray, mask: npt.NDArray[np.boo...
null
173,203
from __future__ import annotations from typing import Callable import numpy as np from pandas._libs import missing as libmissing from pandas._typing import ( AxisInt, npt, ) from pandas.core.nanops import check_below_min_count def _reductions( func: Callable, values: np.ndarray, mask: npt.NDArray[np...
null
173,204
from __future__ import annotations from typing import Callable import numpy as np from pandas._libs import missing as libmissing from pandas._typing import ( AxisInt, npt, ) from pandas.core.nanops import check_below_min_count def _reductions( func: Callable, values: np.ndarray, mask: npt.NDArray[np...
null
173,205
from __future__ import annotations from typing import Callable import numpy as np from pandas._libs import missing as libmissing from pandas._typing import ( AxisInt, npt, ) from pandas.core.nanops import check_below_min_count def _reductions( func: Callable, values: np.ndarray, mask: npt.NDArray[np...
null
173,206
from __future__ import annotations import operator def radd(left, right): return right + left
null
173,207
from __future__ import annotations import operator def rsub(left, right): return right - left
null
173,208
from __future__ import annotations import operator def rmul(left, right): return right * left
null
173,209
from __future__ import annotations import operator def rdiv(left, right): return right / left
null
173,210
from __future__ import annotations import operator def rtruediv(left, right): return right / left
null
173,211
from __future__ import annotations import operator def rfloordiv(left, right): return right // left
null
173,212
from __future__ import annotations import operator def rmod(left, right): # check if right is a string as % is the string # formatting operation; this is a TypeError # otherwise perform the op if isinstance(right, str): typ = type(left).__name__ raise TypeError(f"{typ} cannot perform th...
null
173,213
from __future__ import annotations import operator def rdivmod(left, right): return divmod(right, left)
null
173,214
from __future__ import annotations import operator def rpow(left, right): return right**left
null
173,215
from __future__ import annotations import operator def rand_(left, right): return operator.and_(right, left)
null
173,216
from __future__ import annotations import operator def ror_(left, right): return operator.or_(right, left)
null
173,217
from __future__ import annotations import operator def rxor(left, right): return operator.xor(right, left)
null
173,218
from __future__ import annotations import builtins from collections import ( abc, defaultdict, ) import contextlib from functools import partial import inspect from typing import ( TYPE_CHECKING, Any, Callable, Collection, Generator, Hashable, Iterable, Sequence, cast, ov...
null
173,219
from __future__ import annotations import builtins from collections import ( abc, defaultdict, ) import contextlib from functools import partial import inspect from typing import ( TYPE_CHECKING, Any, Callable, Collection, Generator, Hashable, Iterable, Sequence, cast, ov...
Check whether `key` is a valid boolean indexer. Parameters ---------- key : Any Only list-likes may be considered boolean indexers. All other types are not considered a boolean indexer. For array-like input, boolean ndarrays or ExtensionArrays with ``_is_boolean`` set are considered boolean indexers. Returns ------- bo...
173,220
from __future__ import annotations import builtins from collections import ( abc, defaultdict, ) import contextlib from functools import partial import inspect from typing import ( TYPE_CHECKING, Any, Callable, Collection, Generator, Hashable, Iterable, Sequence, cast, ov...
Disallow indexing with a float key, even if that key is a round number. Parameters ---------- val : scalar Returns ------- outval : scalar
173,221
from __future__ import annotations import builtins from collections import ( abc, defaultdict, ) import contextlib from functools import partial import inspect from typing import ( TYPE_CHECKING, Any, Callable, Collection, Generator, Hashable, Iterable, Sequence, cast, ov...
Returns a boolean indicating if all arguments are None.
173,222
from __future__ import annotations import builtins from collections import ( abc, defaultdict, ) import contextlib from functools import partial import inspect from typing import ( TYPE_CHECKING, Any, Callable, Collection, Generator, Hashable, Iterable, Sequence, cast, ov...
Transform label or iterable of labels to array, for use in Index. Parameters ---------- dtype : dtype If specified, use as dtype of the resulting array, otherwise infer. Returns ------- array
173,223
from __future__ import annotations import builtins from collections import ( abc, defaultdict, ) import contextlib from functools import partial import inspect from typing import ( TYPE_CHECKING, Any, Callable, Collection, Generator, Hashable, Iterable, Sequence, cast, ov...
null
173,224
from __future__ import annotations import builtins from collections import ( abc, defaultdict, ) import contextlib from functools import partial import inspect from typing import ( TYPE_CHECKING, Any, Callable, Collection, Generator, Hashable, Iterable, Sequence, cast, ov...
We have an empty slice, e.g. no values are selected.
173,225
from __future__ import annotations import builtins from collections import ( abc, defaultdict, ) import contextlib from functools import partial import inspect from typing import ( TYPE_CHECKING, Any, Callable, Collection, Generator, Hashable, Iterable, Sequence, cast, ov...
Find non-trivial slices in "line": return a list of booleans with same length.
173,226
from __future__ import annotations import builtins from collections import ( abc, defaultdict, ) import contextlib from functools import partial import inspect from typing import ( TYPE_CHECKING, Any, Callable, Collection, Generator, Hashable, Iterable, Sequence, cast, ov...
We have a full length slice.
173,227
from __future__ import annotations import builtins from collections import ( abc, defaultdict, ) import contextlib from functools import partial import inspect from typing import ( TYPE_CHECKING, Any, Callable, Collection, Generator, Hashable, Iterable, Sequence, cast, ov...
Evaluate possibly callable input using obj and kwargs if it is callable, otherwise return as it is. Parameters ---------- maybe_callable : possibly a callable obj : NDFrame **kwargs
173,228
from __future__ import annotations import builtins from collections import ( abc, defaultdict, ) import contextlib from functools import partial import inspect from typing import ( TYPE_CHECKING, Any, Callable, Collection, Generator, Hashable, Iterable, Sequence, cast, ov...
Apply a function ``func`` to object ``obj`` either by passing obj as the first argument to the function or, in the case that the func is a tuple, interpret the first element of the tuple as a function and pass the obj to that function as a keyword argument whose key is the value of the second element of the tuple. Para...
173,229
from __future__ import annotations import builtins from collections import ( abc, defaultdict, ) import contextlib from functools import partial import inspect from typing import ( TYPE_CHECKING, Any, Callable, Collection, Generator, Hashable, Iterable, Sequence, cast, ov...
Returns a function that will map names/labels, dependent if mapper is a dict, Series or just a function.
173,230
from __future__ import annotations import builtins from collections import ( abc, defaultdict, ) import contextlib from functools import partial import inspect from typing import ( TYPE_CHECKING, Any, Callable, Collection, Generator, Hashable, Iterable, Sequence, cast, ov...
Temporarily set attribute on an object. Args: obj: Object whose attribute will be modified. attr: Attribute to modify. value: Value to temporarily set attribute to. Yields: obj with modified attribute.
173,231
from __future__ import annotations import builtins from collections import ( abc, defaultdict, ) import contextlib from functools import partial import inspect from typing import ( TYPE_CHECKING, Any, Callable, Collection, Generator, Hashable, Iterable, Sequence, cast, ov...
if we define an internal function for this argument, return it
173,232
from __future__ import annotations import builtins from collections import ( abc, defaultdict, ) import contextlib from functools import partial import inspect from typing import ( TYPE_CHECKING, Any, Callable, Collection, Generator, Hashable, Iterable, Sequence, cast, ov...
if we define a builtin function for this argument, return it, otherwise return the arg
173,233
from __future__ import annotations import copy from textwrap import dedent from typing import ( TYPE_CHECKING, Callable, Hashable, Literal, cast, final, no_type_check, ) import warnings import numpy as np from pandas._libs import lib from pandas._libs.tslibs import ( BaseOffset, Inco...
Create a TimeGrouper and return our resampler.
173,234
from __future__ import annotations import copy from textwrap import dedent from typing import ( TYPE_CHECKING, Callable, Hashable, Literal, cast, final, no_type_check, ) import warnings import numpy as np from pandas._libs import lib from pandas._libs.tslibs import ( BaseOffset, Inco...
Return our appropriate resampler when grouping as well.
173,235
from __future__ import annotations import copy from textwrap import dedent from typing import ( TYPE_CHECKING, Callable, Hashable, Literal, cast, final, no_type_check, ) import warnings import numpy as np from pandas._libs import lib from pandas._libs.tslibs import ( BaseOffset, Inco...
null
173,236
from __future__ import annotations import copy from textwrap import dedent from typing import ( TYPE_CHECKING, Callable, Hashable, Literal, cast, final, no_type_check, ) import warnings import numpy as np from pandas._libs import lib from pandas._libs.tslibs import ( BaseOffset, Inco...
Adjust the provided `first` and `last` Periods to the respective Period of the given offset that encompasses them. Parameters ---------- first : pd.Period The beginning Period of the range to be adjusted. last : pd.Period The ending Period of the range to be adjusted. freq : pd.DateOffset The freq to which the Periods ...
173,237
from __future__ import annotations import copy from textwrap import dedent from typing import ( TYPE_CHECKING, Callable, Hashable, Literal, cast, final, no_type_check, ) import warnings import numpy as np from pandas._libs import lib from pandas._libs.tslibs import ( BaseOffset, Inco...
null
173,238
from __future__ import annotations import copy from textwrap import dedent from typing import ( TYPE_CHECKING, Callable, Hashable, Literal, cast, final, no_type_check, ) import warnings import numpy as np from pandas._libs import lib from pandas._libs.tslibs import ( BaseOffset, Inco...
Warn for deprecation of args and kwargs in resample functions. Parameters ---------- cls : type Class to warn about. kernel : str Operation name. args : tuple or None args passed by user. Will be None if and only if kernel does not have args. kwargs : dict or None kwargs passed by user. Will be None if and only if kern...
173,239
from __future__ import annotations from functools import ( partial, wraps, ) from typing import ( TYPE_CHECKING, Any, cast, ) import numpy as np from pandas._libs import ( NaT, algos, lib, ) from pandas._typing import ( ArrayLike, Axis, AxisInt, F, npt, ) from pandas....
Validate the size of the values passed to ExtensionArray.fillna.
173,240
from __future__ import annotations from functools import ( partial, wraps, ) from typing import ( TYPE_CHECKING, Any, cast, ) import numpy as np from pandas._libs import ( NaT, algos, lib, ) from pandas._typing import ( ArrayLike, Axis, AxisInt, F, npt, ) from pandas....
Return a masking array of same size/shape as arr with entries equaling any member of values_to_mask set to True Parameters ---------- arr : ArrayLike values_to_mask: list, tuple, or scalar Returns ------- np.ndarray[bool]
173,241
from __future__ import annotations from functools import ( partial, wraps, ) from typing import ( TYPE_CHECKING, Any, cast, ) import numpy as np from pandas._libs import ( NaT, algos, lib, ) from pandas._typing import ( ArrayLike, Axis, AxisInt, F, npt, ) from pandas....
Wrapper to dispatch to either interpolate_2d or _interpolate_2d_with_fill. Notes ----- Alters 'data' in-place.
173,242
from __future__ import annotations from functools import ( partial, wraps, ) from typing import ( TYPE_CHECKING, Any, cast, ) import numpy as np from pandas._libs import ( NaT, algos, lib, ) from pandas._typing import ( ArrayLike, Axis, AxisInt, F, npt, ) from pandas....
Wrapper to handle datetime64 and timedelta64 dtypes.
173,243
from __future__ import annotations from functools import ( partial, wraps, ) from typing import ( TYPE_CHECKING, Any, cast, ) import numpy as np from pandas._libs import ( NaT, algos, lib, ) from pandas._typing import ( ArrayLike, Axis, AxisInt, F, npt, ) from pandas....
null
173,244
from __future__ import annotations from functools import ( partial, wraps, ) from typing import ( TYPE_CHECKING, Any, cast, ) import numpy as np from pandas._libs import ( NaT, algos, lib, ) from pandas._typing import ( ArrayLike, Axis, AxisInt, F, npt, ) from pandas....
null
173,245
from __future__ import annotations from functools import ( partial, wraps, ) from typing import ( TYPE_CHECKING, Any, cast, ) import numpy as np from pandas._libs import ( NaT, algos, lib, ) from pandas._typing import ( ArrayLike, Axis, AxisInt, F, npt, ) from pandas....
null
173,246
from __future__ import annotations from functools import ( partial, wraps, ) from typing import ( TYPE_CHECKING, Any, cast, ) import numpy as np from pandas._libs import ( NaT, algos, lib, ) from pandas._typing import ( ArrayLike, Axis, AxisInt, F, npt, ) from pandas....
null
173,247
from __future__ import annotations import ast from functools import ( partial, reduce, ) from keyword import iskeyword import tokenize from typing import ( Callable, TypeVar, ) import numpy as np from pandas.compat import PY39 from pandas.errors import UndefinedVariableError import pandas.core.common as...
Compose a collection of tokenization functions. Parameters ---------- source : str A Python source code string f : callable This takes a tuple of (toknum, tokval) as its argument and returns a tuple with the same structure but possibly different elements. Defaults to the composition of ``_rewrite_assign``, ``_replace_b...
173,248
from __future__ import annotations import ast from functools import ( partial, reduce, ) from keyword import iskeyword import tokenize from typing import ( Callable, TypeVar, ) import numpy as np from pandas.compat import PY39 from pandas.errors import UndefinedVariableError import pandas.core.common as...
Factory for a type checking function of type ``t`` or tuple of types.
173,249
from __future__ import annotations import ast from functools import ( partial, reduce, ) from keyword import iskeyword import tokenize from typing import ( Callable, TypeVar, ) import numpy as np from pandas.compat import PY39 from pandas.errors import UndefinedVariableError import pandas.core.common as...
Filter out AST nodes that are subclasses of ``superclass``.
173,250
from __future__ import annotations import ast from functools import ( partial, reduce, ) from keyword import iskeyword import tokenize from typing import ( Callable, TypeVar, ) import numpy as np from pandas.compat import PY39 from pandas.errors import UndefinedVariableError import pandas.core.common as...
Decorator to disallow certain nodes from parsing. Raises a NotImplementedError instead. Returns ------- callable
173,251
from __future__ import annotations import ast from functools import ( partial, reduce, ) from keyword import iskeyword import tokenize from typing import ( Callable, TypeVar, ) import numpy as np from pandas.compat import PY39 from pandas.errors import UndefinedVariableError import pandas.core.common as...
Decorator to add default implementation of ops.
173,252
from __future__ import annotations import datetime import inspect from io import StringIO import itertools import pprint import struct import sys from typing import ( ChainMap, TypeVar, ) import numpy as np from pandas._libs.tslibs import Timestamp from pandas.errors import UndefinedVariableError def _replacer(...
Return the padded hexadecimal id of ``obj``.
173,253
from __future__ import annotations import datetime import inspect from io import StringIO import itertools import pprint import struct import sys from typing import ( ChainMap, TypeVar, ) import numpy as np from pandas._libs.tslibs import Timestamp from pandas.errors import UndefinedVariableError class StringI...
Return a prettier version of obj. Parameters ---------- obj : object Object to pretty print Returns ------- str Pretty print object repr
173,254
from __future__ import annotations import abc from typing import TYPE_CHECKING from pandas.errors import NumExprClobberingError from pandas.core.computation.align import ( align_terms, reconstruct_object, ) from pandas.core.computation.ops import ( MATHOPS, REDUCTIONS, ) from pandas.io.formats import pr...
Attempt to prevent foot-shooting in a helpful way. Parameters ---------- expr : Expr Terms can contain
173,255
from __future__ import annotations from io import StringIO from keyword import iskeyword import token import tokenize from typing import ( Hashable, Iterator, ) def create_valid_python_identifier(name: str) -> str: """ Create valid Python identifiers from any string. Check if name contains any speci...
Function to emulate the cleaning of a backtick quoted name. The purpose for this function is to see what happens to the name of identifier if it goes to the process of being parsed a Python code inside a backtick quoted string and than being cleaned (removed of any special characters). Parameters ---------- name : hash...
173,256
from __future__ import annotations import operator import warnings import numpy as np from pandas._config import get_option from pandas._typing import FuncType from pandas.util._exceptions import find_stack_level from pandas.core.computation.check import NUMEXPR_INSTALLED from pandas.core.ops import roperator if NUMEXP...
null
173,257
from __future__ import annotations import operator import warnings import numpy as np from pandas._config import get_option from pandas._typing import FuncType from pandas.util._exceptions import find_stack_level from pandas.core.computation.check import NUMEXPR_INSTALLED from pandas.core.ops import roperator _TEST_MOD...
Keeps track of whether numexpr was used. Stores an additional ``True`` for every successful use of evaluate with numexpr since the last ``get_test_result``.
173,258
from __future__ import annotations import operator import warnings import numpy as np from pandas._config import get_option from pandas._typing import FuncType from pandas.util._exceptions import find_stack_level from pandas.core.computation.check import NUMEXPR_INSTALLED from pandas.core.ops import roperator _TEST_RES...
Get test result and reset test_results.
173,259
from __future__ import annotations import ast from functools import partial from typing import Any import numpy as np from pandas._libs.tslibs import ( Timedelta, Timestamp, ) from pandas._typing import npt from pandas.errors import UndefinedVariableError from pandas.core.dtypes.common import is_list_like impor...
Validate that the where statement is of the right type. The type may either be String, Expr, or list-like of Exprs. Parameters ---------- w : String term expression, Expr, or list-like of Exprs. Returns ------- where : The original where clause if the check was successful. Raises ------ TypeError : An invalid data type...
173,260
from __future__ import annotations from datetime import datetime from functools import partial import operator from typing import ( Callable, Iterable, Iterator, Literal, ) import numpy as np from pandas._libs.tslibs import Timestamp from pandas.core.dtypes.common import ( is_list_like, is_scala...
Compute the vectorized membership of ``x in y`` if possible, otherwise use Python.
173,261
from __future__ import annotations from datetime import datetime from functools import partial import operator from typing import ( Callable, Iterable, Iterator, Literal, ) import numpy as np from pandas._libs.tslibs import Timestamp from pandas.core.dtypes.common import ( is_list_like, is_scala...
Compute the vectorized membership of ``x not in y`` if possible, otherwise use Python.
173,262
from __future__ import annotations from datetime import datetime from functools import partial import operator from typing import ( Callable, Iterable, Iterator, Literal, ) import numpy as np from pandas._libs.tslibs import Timestamp from pandas.core.dtypes.common import ( is_list_like, is_scala...
Cast an expression inplace. Parameters ---------- terms : Op The expression that should cast. acceptable_dtypes : list of acceptable numpy.dtype Will not cast if term's dtype in this list. dtype : str or numpy.dtype The dtype to cast to.
173,263
from __future__ import annotations from datetime import datetime from functools import partial import operator from typing import ( Callable, Iterable, Iterator, Literal, ) import numpy as np from pandas._libs.tslibs import Timestamp from pandas.core.dtypes.common import ( is_list_like, is_scala...
null
173,264
from __future__ import annotations from datetime import datetime from functools import partial import operator from typing import ( Callable, Iterable, Iterator, Literal, ) import numpy as np from pandas._libs.tslibs import Timestamp from pandas.core.dtypes.common import ( is_list_like, is_scala...
null
173,265
from __future__ import annotations from functools import reduce import numpy as np from pandas._config import get_option The provided code snippet includes necessary dependencies for implementing the `ensure_decoded` function. Write a Python function `def ensure_decoded(s) -> str` to solve the following problem: If we...
If we have bytes, decode them to unicode.
173,266
from __future__ import annotations import tokenize from typing import TYPE_CHECKING import warnings from pandas.util._exceptions import find_stack_level from pandas.util._validators import validate_bool_kwarg from pandas.core.dtypes.common import is_extension_array_dtype from pandas.core.computation.engines import ENGI...
Evaluate a Python expression as a string using various backends. The following arithmetic operations are supported: ``+``, ``-``, ``*``, ``/``, ``**``, ``%``, ``//`` (python engine only) along with the following boolean operations: ``|`` (or), ``&`` (and), and ``~`` (not). Additionally, the ``'pandas'`` parser allows t...
173,267
from __future__ import annotations from functools import ( partial, wraps, ) from typing import ( TYPE_CHECKING, Callable, Sequence, ) import warnings import numpy as np from pandas.errors import PerformanceWarning from pandas.util._exceptions import find_stack_level from pandas.core.dtypes.generic ...
null
173,268
from __future__ import annotations from functools import ( partial, wraps, ) from typing import ( TYPE_CHECKING, Callable, Sequence, ) import warnings import numpy as np from pandas.errors import PerformanceWarning from pandas.util._exceptions import find_stack_level from pandas.core.dtypes.generic ...
Align a set of terms.
173,269
from __future__ import annotations from functools import ( partial, wraps, ) from typing import ( TYPE_CHECKING, Callable, Sequence, ) import warnings import numpy as np from pandas.errors import PerformanceWarning from pandas.util._exceptions import find_stack_level from pandas.core.dtypes.generic ...
Reconstruct an object given its type, raw value, and possibly empty (None) axes. Parameters ---------- typ : object A type obj : object The value to use in the type constructor axes : dict The axes to use to construct the resulting pandas object Returns ------- ret : typ An object of type ``typ`` with the value `obj` a...
173,270
from __future__ import annotations from typing import ( Callable, final, ) import warnings from pandas.util._decorators import doc from pandas.util._exceptions import find_stack_level class Callable(BaseTypingInstance): def py__call__(self, arguments): """ def x() -> Callable[[Callable[...
Add delegated names to a class using a class decorator. This provides an alternative usage to directly calling `_add_delegate_accessors` below a class definition. Parameters ---------- delegate : object The class to get methods/properties & doc-strings. accessors : Sequence[str] List of accessor to add. typ : {'propert...
173,271
from __future__ import annotations from typing import ( Callable, final, ) import warnings from pandas.util._decorators import doc from pandas.util._exceptions import find_stack_level def _register_accessor(name, cls): def register_dataframe_accessor(name): from pandas import DataFrame return _registe...
null
173,272
from __future__ import annotations from typing import ( Callable, final, ) import warnings from pandas.util._decorators import doc from pandas.util._exceptions import find_stack_level def _register_accessor(name, cls): """ Register a custom accessor on {klass} objects. Parameters ---------- ...
null
173,273
from __future__ import annotations from typing import ( Callable, final, ) import warnings from pandas.util._decorators import doc from pandas.util._exceptions import find_stack_level def _register_accessor(name, cls): def register_index_accessor(name): from pandas import Index return _register_access...
null
173,274
from __future__ import annotations import numpy as np from pandas._libs.lib import i8max from pandas._libs.tslibs import ( BaseOffset, OutOfBoundsDatetime, Timedelta, Timestamp, iNaT, ) from pandas._typing import npt def _generate_range_overflow_safe( endpoint: int, periods: int, stride: int, si...
Generate a range of dates or timestamps with the spans between dates described by the given `freq` DateOffset. Parameters ---------- start : Timedelta, Timestamp or None First point of produced date range. end : Timedelta, Timestamp or None Last point of produced date range. periods : int or None Number of periods in p...
173,275
from __future__ import annotations from csv import QUOTE_NONNUMERIC from functools import partial import operator from shutil import get_terminal_size from typing import ( TYPE_CHECKING, Hashable, Iterator, Literal, Sequence, TypeVar, cast, overload, ) import numpy as np from pandas._con...
null
173,276
from __future__ import annotations from csv import QUOTE_NONNUMERIC from functools import partial import operator from shutil import get_terminal_size from typing import ( TYPE_CHECKING, Hashable, Iterator, Literal, Sequence, TypeVar, cast, overload, ) import numpy as np from pandas._con...
Helper for membership check for ``key`` in ``cat``. This is a helper method for :method:`__contains__` and :class:`CategoricalIndex.__contains__`. Returns True if ``key`` is in ``cat.categories`` and the location of ``key`` in ``categories`` is in ``container``. Parameters ---------- cat : :class:`Categorical`or :class...
173,277
from __future__ import annotations from csv import QUOTE_NONNUMERIC from functools import partial import operator from shutil import get_terminal_size from typing import ( TYPE_CHECKING, Hashable, Iterator, Literal, Sequence, TypeVar, cast, overload, ) import numpy as np from pandas._con...
utility routine to turn values into codes given the specified categories If `values` is known to be a Categorical, use recode_for_categories instead.
173,278
from __future__ import annotations import numbers from typing import ( TYPE_CHECKING, cast, ) import numpy as np from pandas._libs import ( lib, missing as libmissing, ) from pandas._typing import ( Dtype, DtypeObj, type_t, ) from pandas.core.dtypes.common import ( is_list_like, is_n...
Coerce the input values array to numpy arrays with a mask. Parameters ---------- values : 1D list-like mask : bool 1D array, optional copy : bool, default False if True, copy the input Returns ------- tuple of (values, mask)
173,279
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...
For PeriodArray methods, dispatch to DatetimeArray and re-wrap the results in PeriodArray. We cannot use ._ndarray directly for the affected methods because the i8 data has different semantics on NaT values.