repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
pandas-dev/pandas
pandas/core/ops.py
_get_method_wrappers
def _get_method_wrappers(cls): """ Find the appropriate operation-wrappers to use when defining flex/special arithmetic, boolean, and comparison operations with the given class. Parameters ---------- cls : class Returns ------- arith_flex : function or None comp_flex : function...
python
def _get_method_wrappers(cls): """ Find the appropriate operation-wrappers to use when defining flex/special arithmetic, boolean, and comparison operations with the given class. Parameters ---------- cls : class Returns ------- arith_flex : function or None comp_flex : function...
[ "def", "_get_method_wrappers", "(", "cls", ")", ":", "if", "issubclass", "(", "cls", ",", "ABCSparseSeries", ")", ":", "# Be sure to catch this before ABCSeries and ABCSparseArray,", "# as they will both come see SparseSeries as a subclass", "arith_flex", "=", "_flex_method_SERIE...
Find the appropriate operation-wrappers to use when defining flex/special arithmetic, boolean, and comparison operations with the given class. Parameters ---------- cls : class Returns ------- arith_flex : function or None comp_flex : function or None arith_special : function c...
[ "Find", "the", "appropriate", "operation", "-", "wrappers", "to", "use", "when", "defining", "flex", "/", "special", "arithmetic", "boolean", "and", "comparison", "operations", "with", "the", "given", "class", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1417-L1473
train
pandas-dev/pandas
pandas/core/ops.py
add_special_arithmetic_methods
def add_special_arithmetic_methods(cls): """ Adds the full suite of special arithmetic methods (``__add__``, ``__sub__``, etc.) to the class. Parameters ---------- cls : class special methods will be defined and pinned to this class """ _, _, arith_method, comp_method, bool_meth...
python
def add_special_arithmetic_methods(cls): """ Adds the full suite of special arithmetic methods (``__add__``, ``__sub__``, etc.) to the class. Parameters ---------- cls : class special methods will be defined and pinned to this class """ _, _, arith_method, comp_method, bool_meth...
[ "def", "add_special_arithmetic_methods", "(", "cls", ")", ":", "_", ",", "_", ",", "arith_method", ",", "comp_method", ",", "bool_method", "=", "_get_method_wrappers", "(", "cls", ")", "new_methods", "=", "_create_methods", "(", "cls", ",", "arith_method", ",", ...
Adds the full suite of special arithmetic methods (``__add__``, ``__sub__``, etc.) to the class. Parameters ---------- cls : class special methods will be defined and pinned to this class
[ "Adds", "the", "full", "suite", "of", "special", "arithmetic", "methods", "(", "__add__", "__sub__", "etc", ".", ")", "to", "the", "class", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1551-L1599
train
pandas-dev/pandas
pandas/core/ops.py
add_flex_arithmetic_methods
def add_flex_arithmetic_methods(cls): """ Adds the full suite of flex arithmetic methods (``pow``, ``mul``, ``add``) to the class. Parameters ---------- cls : class flex methods will be defined and pinned to this class """ flex_arith_method, flex_comp_method, _, _, _ = _get_meth...
python
def add_flex_arithmetic_methods(cls): """ Adds the full suite of flex arithmetic methods (``pow``, ``mul``, ``add``) to the class. Parameters ---------- cls : class flex methods will be defined and pinned to this class """ flex_arith_method, flex_comp_method, _, _, _ = _get_meth...
[ "def", "add_flex_arithmetic_methods", "(", "cls", ")", ":", "flex_arith_method", ",", "flex_comp_method", ",", "_", ",", "_", ",", "_", "=", "_get_method_wrappers", "(", "cls", ")", "new_methods", "=", "_create_methods", "(", "cls", ",", "flex_arith_method", ","...
Adds the full suite of flex arithmetic methods (``pow``, ``mul``, ``add``) to the class. Parameters ---------- cls : class flex methods will be defined and pinned to this class
[ "Adds", "the", "full", "suite", "of", "flex", "arithmetic", "methods", "(", "pow", "mul", "add", ")", "to", "the", "class", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1602-L1622
train
pandas-dev/pandas
pandas/core/ops.py
_align_method_SERIES
def _align_method_SERIES(left, right, align_asobject=False): """ align lhs and rhs Series """ # ToDo: Different from _align_method_FRAME, list, tuple and ndarray # are not coerced here # because Series has inconsistencies described in #13637 if isinstance(right, ABCSeries): # avoid repeate...
python
def _align_method_SERIES(left, right, align_asobject=False): """ align lhs and rhs Series """ # ToDo: Different from _align_method_FRAME, list, tuple and ndarray # are not coerced here # because Series has inconsistencies described in #13637 if isinstance(right, ABCSeries): # avoid repeate...
[ "def", "_align_method_SERIES", "(", "left", ",", "right", ",", "align_asobject", "=", "False", ")", ":", "# ToDo: Different from _align_method_FRAME, list, tuple and ndarray", "# are not coerced here", "# because Series has inconsistencies described in #13637", "if", "isinstance", ...
align lhs and rhs Series
[ "align", "lhs", "and", "rhs", "Series" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1628-L1646
train
pandas-dev/pandas
pandas/core/ops.py
_construct_result
def _construct_result(left, result, index, name, dtype=None): """ If the raw op result has a non-None name (e.g. it is an Index object) and the name argument is None, then passing name to the constructor will not be enough; we still need to override the name attribute. """ out = left._constructo...
python
def _construct_result(left, result, index, name, dtype=None): """ If the raw op result has a non-None name (e.g. it is an Index object) and the name argument is None, then passing name to the constructor will not be enough; we still need to override the name attribute. """ out = left._constructo...
[ "def", "_construct_result", "(", "left", ",", "result", ",", "index", ",", "name", ",", "dtype", "=", "None", ")", ":", "out", "=", "left", ".", "_constructor", "(", "result", ",", "index", "=", "index", ",", "dtype", "=", "dtype", ")", "out", "=", ...
If the raw op result has a non-None name (e.g. it is an Index object) and the name argument is None, then passing name to the constructor will not be enough; we still need to override the name attribute.
[ "If", "the", "raw", "op", "result", "has", "a", "non", "-", "None", "name", "(", "e", ".", "g", ".", "it", "is", "an", "Index", "object", ")", "and", "the", "name", "argument", "is", "None", "then", "passing", "name", "to", "the", "constructor", "w...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1649-L1658
train
pandas-dev/pandas
pandas/core/ops.py
_construct_divmod_result
def _construct_divmod_result(left, result, index, name, dtype=None): """divmod returns a tuple of like indexed series instead of a single series. """ return ( _construct_result(left, result[0], index=index, name=name, dtype=dtype), _construct_result(left, result[1],...
python
def _construct_divmod_result(left, result, index, name, dtype=None): """divmod returns a tuple of like indexed series instead of a single series. """ return ( _construct_result(left, result[0], index=index, name=name, dtype=dtype), _construct_result(left, result[1],...
[ "def", "_construct_divmod_result", "(", "left", ",", "result", ",", "index", ",", "name", ",", "dtype", "=", "None", ")", ":", "return", "(", "_construct_result", "(", "left", ",", "result", "[", "0", "]", ",", "index", "=", "index", ",", "name", "=", ...
divmod returns a tuple of like indexed series instead of a single series.
[ "divmod", "returns", "a", "tuple", "of", "like", "indexed", "series", "instead", "of", "a", "single", "series", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1661-L1669
train
pandas-dev/pandas
pandas/core/ops.py
_arith_method_SERIES
def _arith_method_SERIES(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ str_rep = _get_opstr(op, cls) op_name = _get_op_name(op, special) eval_kwargs = _gen_eval_kwargs(op_name) fill_zeros = _gen_fill_zeros(op_name) construct_...
python
def _arith_method_SERIES(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ str_rep = _get_opstr(op, cls) op_name = _get_op_name(op, special) eval_kwargs = _gen_eval_kwargs(op_name) fill_zeros = _gen_fill_zeros(op_name) construct_...
[ "def", "_arith_method_SERIES", "(", "cls", ",", "op", ",", "special", ")", ":", "str_rep", "=", "_get_opstr", "(", "op", ",", "cls", ")", "op_name", "=", "_get_op_name", "(", "op", ",", "special", ")", "eval_kwargs", "=", "_gen_eval_kwargs", "(", "op_name"...
Wrapper function for Series arithmetic operations, to avoid code duplication.
[ "Wrapper", "function", "for", "Series", "arithmetic", "operations", "to", "avoid", "code", "duplication", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1672-L1770
train
pandas-dev/pandas
pandas/core/ops.py
_comp_method_SERIES
def _comp_method_SERIES(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ op_name = _get_op_name(op, special) masker = _gen_eval_kwargs(op_name).get('masker', False) def na_op(x, y): # TODO: # should have guarantess on w...
python
def _comp_method_SERIES(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ op_name = _get_op_name(op, special) masker = _gen_eval_kwargs(op_name).get('masker', False) def na_op(x, y): # TODO: # should have guarantess on w...
[ "def", "_comp_method_SERIES", "(", "cls", ",", "op", ",", "special", ")", ":", "op_name", "=", "_get_op_name", "(", "op", ",", "special", ")", "masker", "=", "_gen_eval_kwargs", "(", "op_name", ")", ".", "get", "(", "'masker'", ",", "False", ")", "def", ...
Wrapper function for Series arithmetic operations, to avoid code duplication.
[ "Wrapper", "function", "for", "Series", "arithmetic", "operations", "to", "avoid", "code", "duplication", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1789-L1959
train
pandas-dev/pandas
pandas/core/ops.py
_bool_method_SERIES
def _bool_method_SERIES(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ op_name = _get_op_name(op, special) def na_op(x, y): try: result = op(x, y) except TypeError: assert not isinstance(y, (list, ...
python
def _bool_method_SERIES(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ op_name = _get_op_name(op, special) def na_op(x, y): try: result = op(x, y) except TypeError: assert not isinstance(y, (list, ...
[ "def", "_bool_method_SERIES", "(", "cls", ",", "op", ",", "special", ")", ":", "op_name", "=", "_get_op_name", "(", "op", ",", "special", ")", "def", "na_op", "(", "x", ",", "y", ")", ":", "try", ":", "result", "=", "op", "(", "x", ",", "y", ")",...
Wrapper function for Series arithmetic operations, to avoid code duplication.
[ "Wrapper", "function", "for", "Series", "arithmetic", "operations", "to", "avoid", "code", "duplication", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1962-L2039
train
pandas-dev/pandas
pandas/core/ops.py
_combine_series_frame
def _combine_series_frame(self, other, func, fill_value=None, axis=None, level=None): """ Apply binary operator `func` to self, other using alignment and fill conventions determined by the fill_value, axis, and level kwargs. Parameters ---------- self : DataFrame o...
python
def _combine_series_frame(self, other, func, fill_value=None, axis=None, level=None): """ Apply binary operator `func` to self, other using alignment and fill conventions determined by the fill_value, axis, and level kwargs. Parameters ---------- self : DataFrame o...
[ "def", "_combine_series_frame", "(", "self", ",", "other", ",", "func", ",", "fill_value", "=", "None", ",", "axis", "=", "None", ",", "level", "=", "None", ")", ":", "if", "fill_value", "is", "not", "None", ":", "raise", "NotImplementedError", "(", "\"f...
Apply binary operator `func` to self, other using alignment and fill conventions determined by the fill_value, axis, and level kwargs. Parameters ---------- self : DataFrame other : Series func : binary operator fill_value : object, default None axis : {0, 1, 'columns', 'index', None}, ...
[ "Apply", "binary", "operator", "func", "to", "self", "other", "using", "alignment", "and", "fill", "conventions", "determined", "by", "the", "fill_value", "axis", "and", "level", "kwargs", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L2073-L2112
train
pandas-dev/pandas
pandas/core/ops.py
_align_method_FRAME
def _align_method_FRAME(left, right, axis): """ convert rhs to meet lhs dims if input is list, tuple or np.ndarray """ def to_series(right): msg = ('Unable to coerce to Series, length must be {req_len}: ' 'given {given_len}') if axis is not None and left._get_axis_name(axis) == '...
python
def _align_method_FRAME(left, right, axis): """ convert rhs to meet lhs dims if input is list, tuple or np.ndarray """ def to_series(right): msg = ('Unable to coerce to Series, length must be {req_len}: ' 'given {given_len}') if axis is not None and left._get_axis_name(axis) == '...
[ "def", "_align_method_FRAME", "(", "left", ",", "right", ",", "axis", ")", ":", "def", "to_series", "(", "right", ")", ":", "msg", "=", "(", "'Unable to coerce to Series, length must be {req_len}: '", "'given {given_len}'", ")", "if", "axis", "is", "not", "None", ...
convert rhs to meet lhs dims if input is list, tuple or np.ndarray
[ "convert", "rhs", "to", "meet", "lhs", "dims", "if", "input", "is", "list", "tuple", "or", "np", ".", "ndarray" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L2115-L2169
train
pandas-dev/pandas
pandas/core/ops.py
_cast_sparse_series_op
def _cast_sparse_series_op(left, right, opname): """ For SparseSeries operation, coerce to float64 if the result is expected to have NaN or inf values Parameters ---------- left : SparseArray right : SparseArray opname : str Returns ------- left : SparseArray right : Sp...
python
def _cast_sparse_series_op(left, right, opname): """ For SparseSeries operation, coerce to float64 if the result is expected to have NaN or inf values Parameters ---------- left : SparseArray right : SparseArray opname : str Returns ------- left : SparseArray right : Sp...
[ "def", "_cast_sparse_series_op", "(", "left", ",", "right", ",", "opname", ")", ":", "from", "pandas", ".", "core", ".", "sparse", ".", "api", "import", "SparseDtype", "opname", "=", "opname", ".", "strip", "(", "'_'", ")", "# TODO: This should be moved to the...
For SparseSeries operation, coerce to float64 if the result is expected to have NaN or inf values Parameters ---------- left : SparseArray right : SparseArray opname : str Returns ------- left : SparseArray right : SparseArray
[ "For", "SparseSeries", "operation", "coerce", "to", "float64", "if", "the", "result", "is", "expected", "to", "have", "NaN", "or", "inf", "values" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L2389-L2419
train
pandas-dev/pandas
pandas/core/ops.py
_arith_method_SPARSE_SERIES
def _arith_method_SPARSE_SERIES(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ op_name = _get_op_name(op, special) def wrapper(self, other): if isinstance(other, ABCDataFrame): return NotImplemented elif isins...
python
def _arith_method_SPARSE_SERIES(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ op_name = _get_op_name(op, special) def wrapper(self, other): if isinstance(other, ABCDataFrame): return NotImplemented elif isins...
[ "def", "_arith_method_SPARSE_SERIES", "(", "cls", ",", "op", ",", "special", ")", ":", "op_name", "=", "_get_op_name", "(", "op", ",", "special", ")", "def", "wrapper", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "ABCDataF...
Wrapper function for Series arithmetic operations, to avoid code duplication.
[ "Wrapper", "function", "for", "Series", "arithmetic", "operations", "to", "avoid", "code", "duplication", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L2422-L2447
train
pandas-dev/pandas
pandas/core/ops.py
_arith_method_SPARSE_ARRAY
def _arith_method_SPARSE_ARRAY(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ op_name = _get_op_name(op, special) def wrapper(self, other): from pandas.core.arrays.sparse.array import ( SparseArray, _sparse_array_op, ...
python
def _arith_method_SPARSE_ARRAY(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ op_name = _get_op_name(op, special) def wrapper(self, other): from pandas.core.arrays.sparse.array import ( SparseArray, _sparse_array_op, ...
[ "def", "_arith_method_SPARSE_ARRAY", "(", "cls", ",", "op", ",", "special", ")", ":", "op_name", "=", "_get_op_name", "(", "op", ",", "special", ")", "def", "wrapper", "(", "self", ",", "other", ")", ":", "from", "pandas", ".", "core", ".", "arrays", "...
Wrapper function for Series arithmetic operations, to avoid code duplication.
[ "Wrapper", "function", "for", "Series", "arithmetic", "operations", "to", "avoid", "code", "duplication", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L2461-L2491
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
validate_periods
def validate_periods(periods): """ 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 peri...
python
def validate_periods(periods): """ 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 peri...
[ "def", "validate_periods", "(", "periods", ")", ":", "if", "periods", "is", "not", "None", ":", "if", "lib", ".", "is_float", "(", "periods", ")", ":", "periods", "=", "int", "(", "periods", ")", "elif", "not", "lib", ".", "is_integer", "(", "periods",...
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
[ "If", "a", "periods", "argument", "is", "passed", "to", "the", "Datetime", "/", "Timedelta", "Array", "/", "Index", "constructor", "cast", "it", "to", "an", "integer", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1441-L1465
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
validate_endpoints
def validate_endpoints(closed): """ Check that the `closed` argument is among [None, "left", "right"] Parameters ---------- closed : {None, "left", "right"} Returns ------- left_closed : bool right_closed : bool Raises ------ ValueError : if argument is not among valid...
python
def validate_endpoints(closed): """ Check that the `closed` argument is among [None, "left", "right"] Parameters ---------- closed : {None, "left", "right"} Returns ------- left_closed : bool right_closed : bool Raises ------ ValueError : if argument is not among valid...
[ "def", "validate_endpoints", "(", "closed", ")", ":", "left_closed", "=", "False", "right_closed", "=", "False", "if", "closed", "is", "None", ":", "left_closed", "=", "True", "right_closed", "=", "True", "elif", "closed", "==", "\"left\"", ":", "left_closed",...
Check that the `closed` argument is among [None, "left", "right"] Parameters ---------- closed : {None, "left", "right"} Returns ------- left_closed : bool right_closed : bool Raises ------ ValueError : if argument is not among valid values
[ "Check", "that", "the", "closed", "argument", "is", "among", "[", "None", "left", "right", "]" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1468-L1498
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
validate_inferred_freq
def validate_inferred_freq(freq, inferred_freq, freq_infer): """ 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 ------...
python
def validate_inferred_freq(freq, inferred_freq, freq_infer): """ 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 ------...
[ "def", "validate_inferred_freq", "(", "freq", ",", "inferred_freq", ",", "freq_infer", ")", ":", "if", "inferred_freq", "is", "not", "None", ":", "if", "freq", "is", "not", "None", "and", "freq", "!=", "inferred_freq", ":", "raise", "ValueError", "(", "'Infe...
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 ----...
[ "If", "the", "user", "passes", "a", "freq", "and", "another", "freq", "is", "inferred", "from", "passed", "data", "require", "that", "they", "match", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1501-L1533
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
maybe_infer_freq
def maybe_infer_freq(freq): """ Comparing a DateOffset to the string "infer" raises, so we need to be careful about comparisons. Make a dummy variable `freq_infer` to signify the case where the given freq is "infer" and set freq to None to avoid comparison trouble later on. Parameters ----...
python
def maybe_infer_freq(freq): """ Comparing a DateOffset to the string "infer" raises, so we need to be careful about comparisons. Make a dummy variable `freq_infer` to signify the case where the given freq is "infer" and set freq to None to avoid comparison trouble later on. Parameters ----...
[ "def", "maybe_infer_freq", "(", "freq", ")", ":", "freq_infer", "=", "False", "if", "not", "isinstance", "(", "freq", ",", "DateOffset", ")", ":", "# if a passed freq is None, don't infer automatically", "if", "freq", "!=", "'infer'", ":", "freq", "=", "frequencie...
Comparing a DateOffset to the string "infer" raises, so we need to be careful about comparisons. Make a dummy variable `freq_infer` to signify the case where the given freq is "infer" and set freq to None to avoid comparison trouble later on. Parameters ---------- freq : {DateOffset, None, str...
[ "Comparing", "a", "DateOffset", "to", "the", "string", "infer", "raises", "so", "we", "need", "to", "be", "careful", "about", "comparisons", ".", "Make", "a", "dummy", "variable", "freq_infer", "to", "signify", "the", "case", "where", "the", "given", "freq",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1536-L1560
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
_ensure_datetimelike_to_i8
def _ensure_datetimelike_to_i8(other, to_utc=False): """ Helper for coercing an input scalar or array to i8. Parameters ---------- other : 1d array to_utc : bool, default False If True, convert the values to UTC before extracting the i8 values If False, extract the i8 values dir...
python
def _ensure_datetimelike_to_i8(other, to_utc=False): """ Helper for coercing an input scalar or array to i8. Parameters ---------- other : 1d array to_utc : bool, default False If True, convert the values to UTC before extracting the i8 values If False, extract the i8 values dir...
[ "def", "_ensure_datetimelike_to_i8", "(", "other", ",", "to_utc", "=", "False", ")", ":", "from", "pandas", "import", "Index", "from", "pandas", ".", "core", ".", "arrays", "import", "PeriodArray", "if", "lib", ".", "is_scalar", "(", "other", ")", "and", "...
Helper for coercing an input scalar or array to i8. Parameters ---------- other : 1d array to_utc : bool, default False If True, convert the values to UTC before extracting the i8 values If False, extract the i8 values directly. Returns ------- i8 1d array
[ "Helper", "for", "coercing", "an", "input", "scalar", "or", "array", "to", "i8", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1563-L1597
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
AttributesMixin._scalar_from_string
def _scalar_from_string( self, value: str, ) -> Union[Period, Timestamp, Timedelta, NaTType]: """ Construct a scalar type from a string. Parameters ---------- value : str Returns ------- Period, Timestamp, or Timedelta, or NaT...
python
def _scalar_from_string( self, value: str, ) -> Union[Period, Timestamp, Timedelta, NaTType]: """ Construct a scalar type from a string. Parameters ---------- value : str Returns ------- Period, Timestamp, or Timedelta, or NaT...
[ "def", "_scalar_from_string", "(", "self", ",", "value", ":", "str", ",", ")", "->", "Union", "[", "Period", ",", "Timestamp", ",", "Timedelta", ",", "NaTType", "]", ":", "raise", "AbstractMethodError", "(", "self", ")" ]
Construct a scalar type from a string. Parameters ---------- value : str Returns ------- Period, Timestamp, or Timedelta, or NaT Whatever the type of ``self._scalar_type`` is. Notes ----- This should call ``self._check_compatible_wit...
[ "Construct", "a", "scalar", "type", "from", "a", "string", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L68-L89
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
AttributesMixin._unbox_scalar
def _unbox_scalar( self, value: Union[Period, Timestamp, Timedelta, NaTType], ) -> int: """ Unbox the integer value of a scalar `value`. Parameters ---------- value : Union[Period, Timestamp, Timedelta] Returns ------- int ...
python
def _unbox_scalar( self, value: Union[Period, Timestamp, Timedelta, NaTType], ) -> int: """ Unbox the integer value of a scalar `value`. Parameters ---------- value : Union[Period, Timestamp, Timedelta] Returns ------- int ...
[ "def", "_unbox_scalar", "(", "self", ",", "value", ":", "Union", "[", "Period", ",", "Timestamp", ",", "Timedelta", ",", "NaTType", "]", ",", ")", "->", "int", ":", "raise", "AbstractMethodError", "(", "self", ")" ]
Unbox the integer value of a scalar `value`. Parameters ---------- value : Union[Period, Timestamp, Timedelta] Returns ------- int Examples -------- >>> self._unbox_scalar(Timedelta('10s')) # DOCTEST: +SKIP 10000000000
[ "Unbox", "the", "integer", "value", "of", "a", "scalar", "value", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L91-L111
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
AttributesMixin._check_compatible_with
def _check_compatible_with( self, other: Union[Period, Timestamp, Timedelta, NaTType], ) -> None: """ Verify that `self` and `other` are compatible. * DatetimeArray verifies that the timezones (if any) match * PeriodArray verifies that the freq matches ...
python
def _check_compatible_with( self, other: Union[Period, Timestamp, Timedelta, NaTType], ) -> None: """ Verify that `self` and `other` are compatible. * DatetimeArray verifies that the timezones (if any) match * PeriodArray verifies that the freq matches ...
[ "def", "_check_compatible_with", "(", "self", ",", "other", ":", "Union", "[", "Period", ",", "Timestamp", ",", "Timedelta", ",", "NaTType", "]", ",", ")", "->", "None", ":", "raise", "AbstractMethodError", "(", "self", ")" ]
Verify that `self` and `other` are compatible. * DatetimeArray verifies that the timezones (if any) match * PeriodArray verifies that the freq matches * Timedelta has no verification In each case, NaT is considered compatible. Parameters ---------- other ...
[ "Verify", "that", "self", "and", "other", "are", "compatible", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L113-L134
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatelikeOps.strftime
def strftime(self, date_format): """ Convert to Index using specified date_format. Return an Index of formatted strings specified by date_format, which supports the same string format as the python standard library. Details of the string format can be found in `python string for...
python
def strftime(self, date_format): """ Convert to Index using specified date_format. Return an Index of formatted strings specified by date_format, which supports the same string format as the python standard library. Details of the string format can be found in `python string for...
[ "def", "strftime", "(", "self", ",", "date_format", ")", ":", "from", "pandas", "import", "Index", "return", "Index", "(", "self", ".", "_format_native_types", "(", "date_format", "=", "date_format", ")", ")" ]
Convert to Index using specified date_format. Return an Index of formatted strings specified by date_format, which supports the same string format as the python standard library. Details of the string format can be found in `python string format doc <%(URL)s>`__. Parameters ...
[ "Convert", "to", "Index", "using", "specified", "date_format", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L144-L180
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin.searchsorted
def searchsorted(self, value, side='left', sorter=None): """ Find indices where elements should be inserted to maintain order. Find the indices into a sorted array `self` such that, if the corresponding elements in `value` were inserted before the indices, the order of `self` wo...
python
def searchsorted(self, value, side='left', sorter=None): """ Find indices where elements should be inserted to maintain order. Find the indices into a sorted array `self` such that, if the corresponding elements in `value` were inserted before the indices, the order of `self` wo...
[ "def", "searchsorted", "(", "self", ",", "value", ",", "side", "=", "'left'", ",", "sorter", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "value", "=", "self", ".", "_scalar_from_string", "(", "value", ")", "if", "no...
Find indices where elements should be inserted to maintain order. Find the indices into a sorted array `self` such that, if the corresponding elements in `value` were inserted before the indices, the order of `self` would be preserved. Parameters ---------- value : arra...
[ "Find", "indices", "where", "elements", "should", "be", "inserted", "to", "maintain", "order", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L627-L666
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin.repeat
def repeat(self, repeats, *args, **kwargs): """ Repeat elements of an array. See Also -------- numpy.ndarray.repeat """ nv.validate_repeat(args, kwargs) values = self._data.repeat(repeats) return type(self)(values.view('i8'), dtype=self.dtype)
python
def repeat(self, repeats, *args, **kwargs): """ Repeat elements of an array. See Also -------- numpy.ndarray.repeat """ nv.validate_repeat(args, kwargs) values = self._data.repeat(repeats) return type(self)(values.view('i8'), dtype=self.dtype)
[ "def", "repeat", "(", "self", ",", "repeats", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "nv", ".", "validate_repeat", "(", "args", ",", "kwargs", ")", "values", "=", "self", ".", "_data", ".", "repeat", "(", "repeats", ")", "return", "ty...
Repeat elements of an array. See Also -------- numpy.ndarray.repeat
[ "Repeat", "elements", "of", "an", "array", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L668-L678
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin.value_counts
def value_counts(self, dropna=False): """ Return a Series containing counts of unique values. Parameters ---------- dropna : boolean, default True Don't include counts of NaT values. Returns ------- Series """ from pandas impo...
python
def value_counts(self, dropna=False): """ Return a Series containing counts of unique values. Parameters ---------- dropna : boolean, default True Don't include counts of NaT values. Returns ------- Series """ from pandas impo...
[ "def", "value_counts", "(", "self", ",", "dropna", "=", "False", ")", ":", "from", "pandas", "import", "Series", ",", "Index", "if", "dropna", ":", "values", "=", "self", "[", "~", "self", ".", "isna", "(", ")", "]", ".", "_data", "else", ":", "val...
Return a Series containing counts of unique values. Parameters ---------- dropna : boolean, default True Don't include counts of NaT values. Returns ------- Series
[ "Return", "a", "Series", "containing", "counts", "of", "unique", "values", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L680-L705
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._maybe_mask_results
def _maybe_mask_results(self, result, fill_value=iNaT, convert=None): """ Parameters ---------- result : a ndarray fill_value : object, default iNaT convert : string/dtype or None Returns ------- result : ndarray with values replace by the fill_va...
python
def _maybe_mask_results(self, result, fill_value=iNaT, convert=None): """ Parameters ---------- result : a ndarray fill_value : object, default iNaT convert : string/dtype or None Returns ------- result : ndarray with values replace by the fill_va...
[ "def", "_maybe_mask_results", "(", "self", ",", "result", ",", "fill_value", "=", "iNaT", ",", "convert", "=", "None", ")", ":", "if", "self", ".", "_hasnans", ":", "if", "convert", ":", "result", "=", "result", ".", "astype", "(", "convert", ")", "if"...
Parameters ---------- result : a ndarray fill_value : object, default iNaT convert : string/dtype or None Returns ------- result : ndarray with values replace by the fill_value mask the result if needed, convert to the provided dtype if its not N...
[ "Parameters", "----------", "result", ":", "a", "ndarray", "fill_value", ":", "object", "default", "iNaT", "convert", ":", "string", "/", "dtype", "or", "None" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L737-L761
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._validate_frequency
def _validate_frequency(cls, index, freq, **kwargs): """ Validate that a frequency is compatible with the values of a given Datetime Array/Index or Timedelta Array/Index Parameters ---------- index : DatetimeIndex or TimedeltaIndex The index on which to deter...
python
def _validate_frequency(cls, index, freq, **kwargs): """ Validate that a frequency is compatible with the values of a given Datetime Array/Index or Timedelta Array/Index Parameters ---------- index : DatetimeIndex or TimedeltaIndex The index on which to deter...
[ "def", "_validate_frequency", "(", "cls", ",", "index", ",", "freq", ",", "*", "*", "kwargs", ")", ":", "if", "is_period_dtype", "(", "cls", ")", ":", "# Frequency validation is not meaningful for Period Array/Index", "return", "None", "inferred", "=", "index", "....
Validate that a frequency is compatible with the values of a given Datetime Array/Index or Timedelta Array/Index Parameters ---------- index : DatetimeIndex or TimedeltaIndex The index on which to determine if the given frequency is valid freq : DateOffset ...
[ "Validate", "that", "a", "frequency", "is", "compatible", "with", "the", "values", "of", "a", "given", "Datetime", "Array", "/", "Index", "or", "Timedelta", "Array", "/", "Index" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L860-L898
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._add_delta
def _add_delta(self, other): """ Add a timedelta-like, Tick or TimedeltaIndex-like object to self, yielding an int64 numpy array Parameters ---------- delta : {timedelta, np.timedelta64, Tick, TimedeltaIndex, ndarray[timedelta64]} Returns ...
python
def _add_delta(self, other): """ Add a timedelta-like, Tick or TimedeltaIndex-like object to self, yielding an int64 numpy array Parameters ---------- delta : {timedelta, np.timedelta64, Tick, TimedeltaIndex, ndarray[timedelta64]} Returns ...
[ "def", "_add_delta", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "(", "Tick", ",", "timedelta", ",", "np", ".", "timedelta64", ")", ")", ":", "new_values", "=", "self", ".", "_add_timedeltalike_scalar", "(", "other", ")", ...
Add a timedelta-like, Tick or TimedeltaIndex-like object to self, yielding an int64 numpy array Parameters ---------- delta : {timedelta, np.timedelta64, Tick, TimedeltaIndex, ndarray[timedelta64]} Returns ------- result : ndarray[int64] ...
[ "Add", "a", "timedelta", "-", "like", "Tick", "or", "TimedeltaIndex", "-", "like", "object", "to", "self", "yielding", "an", "int64", "numpy", "array" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L942-L967
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._add_timedeltalike_scalar
def _add_timedeltalike_scalar(self, other): """ Add a delta of a timedeltalike return the i8 result view """ if isna(other): # i.e np.timedelta64("NaT"), not recognized by delta_to_nanoseconds new_values = np.empty(len(self), dtype='i8') new_va...
python
def _add_timedeltalike_scalar(self, other): """ Add a delta of a timedeltalike return the i8 result view """ if isna(other): # i.e np.timedelta64("NaT"), not recognized by delta_to_nanoseconds new_values = np.empty(len(self), dtype='i8') new_va...
[ "def", "_add_timedeltalike_scalar", "(", "self", ",", "other", ")", ":", "if", "isna", "(", "other", ")", ":", "# i.e np.timedelta64(\"NaT\"), not recognized by delta_to_nanoseconds", "new_values", "=", "np", ".", "empty", "(", "len", "(", "self", ")", ",", "dtype...
Add a delta of a timedeltalike return the i8 result view
[ "Add", "a", "delta", "of", "a", "timedeltalike", "return", "the", "i8", "result", "view" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L969-L984
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._add_delta_tdi
def _add_delta_tdi(self, other): """ Add a delta of a TimedeltaIndex return the i8 result view """ if len(self) != len(other): raise ValueError("cannot add indices of unequal length") if isinstance(other, np.ndarray): # ndarray[timedelta64]; wrap ...
python
def _add_delta_tdi(self, other): """ Add a delta of a TimedeltaIndex return the i8 result view """ if len(self) != len(other): raise ValueError("cannot add indices of unequal length") if isinstance(other, np.ndarray): # ndarray[timedelta64]; wrap ...
[ "def", "_add_delta_tdi", "(", "self", ",", "other", ")", ":", "if", "len", "(", "self", ")", "!=", "len", "(", "other", ")", ":", "raise", "ValueError", "(", "\"cannot add indices of unequal length\"", ")", "if", "isinstance", "(", "other", ",", "np", ".",...
Add a delta of a TimedeltaIndex return the i8 result view
[ "Add", "a", "delta", "of", "a", "TimedeltaIndex", "return", "the", "i8", "result", "view" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L986-L1007
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._add_nat
def _add_nat(self): """ Add pd.NaT to self """ if is_period_dtype(self): raise TypeError('Cannot add {cls} and {typ}' .format(cls=type(self).__name__, typ=type(NaT).__name__)) # GH#19124 pd.NaT is treate...
python
def _add_nat(self): """ Add pd.NaT to self """ if is_period_dtype(self): raise TypeError('Cannot add {cls} and {typ}' .format(cls=type(self).__name__, typ=type(NaT).__name__)) # GH#19124 pd.NaT is treate...
[ "def", "_add_nat", "(", "self", ")", ":", "if", "is_period_dtype", "(", "self", ")", ":", "raise", "TypeError", "(", "'Cannot add {cls} and {typ}'", ".", "format", "(", "cls", "=", "type", "(", "self", ")", ".", "__name__", ",", "typ", "=", "type", "(", ...
Add pd.NaT to self
[ "Add", "pd", ".", "NaT", "to", "self" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1009-L1022
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._sub_nat
def _sub_nat(self): """ Subtract pd.NaT from self """ # GH#19124 Timedelta - datetime is not in general well-defined. # We make an exception for pd.NaT, which in this case quacks # like a timedelta. # For datetime64 dtypes by convention we treat NaT as a datetime,...
python
def _sub_nat(self): """ Subtract pd.NaT from self """ # GH#19124 Timedelta - datetime is not in general well-defined. # We make an exception for pd.NaT, which in this case quacks # like a timedelta. # For datetime64 dtypes by convention we treat NaT as a datetime,...
[ "def", "_sub_nat", "(", "self", ")", ":", "# GH#19124 Timedelta - datetime is not in general well-defined.", "# We make an exception for pd.NaT, which in this case quacks", "# like a timedelta.", "# For datetime64 dtypes by convention we treat NaT as a datetime, so", "# this subtraction returns ...
Subtract pd.NaT from self
[ "Subtract", "pd", ".", "NaT", "from", "self" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1024-L1036
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._sub_period_array
def _sub_period_array(self, other): """ Subtract a Period Array/Index from self. This is only valid if self is itself a Period Array/Index, raises otherwise. Both objects must have the same frequency. Parameters ---------- other : PeriodIndex or PeriodArray ...
python
def _sub_period_array(self, other): """ Subtract a Period Array/Index from self. This is only valid if self is itself a Period Array/Index, raises otherwise. Both objects must have the same frequency. Parameters ---------- other : PeriodIndex or PeriodArray ...
[ "def", "_sub_period_array", "(", "self", ",", "other", ")", ":", "if", "not", "is_period_dtype", "(", "self", ")", ":", "raise", "TypeError", "(", "\"cannot subtract {dtype}-dtype from {cls}\"", ".", "format", "(", "dtype", "=", "other", ".", "dtype", ",", "cl...
Subtract a Period Array/Index from self. This is only valid if self is itself a Period Array/Index, raises otherwise. Both objects must have the same frequency. Parameters ---------- other : PeriodIndex or PeriodArray Returns ------- result : np.ndarra...
[ "Subtract", "a", "Period", "Array", "/", "Index", "from", "self", ".", "This", "is", "only", "valid", "if", "self", "is", "itself", "a", "Period", "Array", "/", "Index", "raises", "otherwise", ".", "Both", "objects", "must", "have", "the", "same", "frequ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1038-L1075
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._addsub_int_array
def _addsub_int_array(self, other, op): """ Add or subtract array-like of integers equivalent to applying `_time_shift` pointwise. Parameters ---------- other : Index, ExtensionArray, np.ndarray integer-dtype op : {operator.add, operator.sub} ...
python
def _addsub_int_array(self, other, op): """ Add or subtract array-like of integers equivalent to applying `_time_shift` pointwise. Parameters ---------- other : Index, ExtensionArray, np.ndarray integer-dtype op : {operator.add, operator.sub} ...
[ "def", "_addsub_int_array", "(", "self", ",", "other", ",", "op", ")", ":", "# _addsub_int_array is overriden by PeriodArray", "assert", "not", "is_period_dtype", "(", "self", ")", "assert", "op", "in", "[", "operator", ".", "add", ",", "operator", ".", "sub", ...
Add or subtract array-like of integers equivalent to applying `_time_shift` pointwise. Parameters ---------- other : Index, ExtensionArray, np.ndarray integer-dtype op : {operator.add, operator.sub} Returns ------- result : same class as self
[ "Add", "or", "subtract", "array", "-", "like", "of", "integers", "equivalent", "to", "applying", "_time_shift", "pointwise", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1077-L1108
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._addsub_offset_array
def _addsub_offset_array(self, other, op): """ Add or subtract array-like of DateOffset objects Parameters ---------- other : Index, np.ndarray object-dtype containing pd.DateOffset objects op : {operator.add, operator.sub} Returns ------- ...
python
def _addsub_offset_array(self, other, op): """ Add or subtract array-like of DateOffset objects Parameters ---------- other : Index, np.ndarray object-dtype containing pd.DateOffset objects op : {operator.add, operator.sub} Returns ------- ...
[ "def", "_addsub_offset_array", "(", "self", ",", "other", ",", "op", ")", ":", "assert", "op", "in", "[", "operator", ".", "add", ",", "operator", ".", "sub", "]", "if", "len", "(", "other", ")", "==", "1", ":", "return", "op", "(", "self", ",", ...
Add or subtract array-like of DateOffset objects Parameters ---------- other : Index, np.ndarray object-dtype containing pd.DateOffset objects op : {operator.add, operator.sub} Returns ------- result : same class as self
[ "Add", "or", "subtract", "array", "-", "like", "of", "DateOffset", "objects" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1110-L1139
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._time_shift
def _time_shift(self, periods, freq=None): """ Shift each value by `periods`. Note this is different from ExtensionArray.shift, which shifts the *position* of each element, padding the end with missing values. Parameters ---------- periods : int ...
python
def _time_shift(self, periods, freq=None): """ Shift each value by `periods`. Note this is different from ExtensionArray.shift, which shifts the *position* of each element, padding the end with missing values. Parameters ---------- periods : int ...
[ "def", "_time_shift", "(", "self", ",", "periods", ",", "freq", "=", "None", ")", ":", "if", "freq", "is", "not", "None", "and", "freq", "!=", "self", ".", "freq", ":", "if", "isinstance", "(", "freq", ",", "str", ")", ":", "freq", "=", "frequencie...
Shift each value by `periods`. Note this is different from ExtensionArray.shift, which shifts the *position* of each element, padding the end with missing values. Parameters ---------- periods : int Number of periods to shift by. freq : pandas.DateOf...
[ "Shift", "each", "value", "by", "periods", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1141-L1177
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._ensure_localized
def _ensure_localized(self, arg, ambiguous='raise', nonexistent='raise', from_utc=False): """ Ensure that we are re-localized. This is for compat as we can then call this on all datetimelike arrays generally (ignored for Period/Timedelta) Parameters ...
python
def _ensure_localized(self, arg, ambiguous='raise', nonexistent='raise', from_utc=False): """ Ensure that we are re-localized. This is for compat as we can then call this on all datetimelike arrays generally (ignored for Period/Timedelta) Parameters ...
[ "def", "_ensure_localized", "(", "self", ",", "arg", ",", "ambiguous", "=", "'raise'", ",", "nonexistent", "=", "'raise'", ",", "from_utc", "=", "False", ")", ":", "# reconvert to local tz", "tz", "=", "getattr", "(", "self", ",", "'tz'", ",", "None", ")",...
Ensure that we are re-localized. This is for compat as we can then call this on all datetimelike arrays generally (ignored for Period/Timedelta) Parameters ---------- arg : Union[DatetimeLikeArray, DatetimeIndexOpsMixin, ndarray] ambiguous : str, bool, or bool-ndarray, ...
[ "Ensure", "that", "we", "are", "re", "-", "localized", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1340-L1373
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin.min
def min(self, axis=None, skipna=True, *args, **kwargs): """ Return the minimum value of the Array or minimum along an axis. See Also -------- numpy.ndarray.min Index.min : Return the minimum value in an Index. Series.min : Return the minimum value in a Se...
python
def min(self, axis=None, skipna=True, *args, **kwargs): """ Return the minimum value of the Array or minimum along an axis. See Also -------- numpy.ndarray.min Index.min : Return the minimum value in an Index. Series.min : Return the minimum value in a Se...
[ "def", "min", "(", "self", ",", "axis", "=", "None", ",", "skipna", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "nv", ".", "validate_min", "(", "args", ",", "kwargs", ")", "nv", ".", "validate_minmax_axis", "(", "axis", ")", ...
Return the minimum value of the Array or minimum along an axis. See Also -------- numpy.ndarray.min Index.min : Return the minimum value in an Index. Series.min : Return the minimum value in a Series.
[ "Return", "the", "minimum", "value", "of", "the", "Array", "or", "minimum", "along", "an", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1385-L1403
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin.max
def max(self, axis=None, skipna=True, *args, **kwargs): """ Return the maximum value of the Array or maximum along an axis. See Also -------- numpy.ndarray.max Index.max : Return the maximum value in an Index. Series.max : Return the maximum value in a Se...
python
def max(self, axis=None, skipna=True, *args, **kwargs): """ Return the maximum value of the Array or maximum along an axis. See Also -------- numpy.ndarray.max Index.max : Return the maximum value in an Index. Series.max : Return the maximum value in a Se...
[ "def", "max", "(", "self", ",", "axis", "=", "None", ",", "skipna", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# TODO: skipna is broken with max.", "# See https://github.com/pandas-dev/pandas/issues/24265", "nv", ".", "validate_max", "(", ...
Return the maximum value of the Array or maximum along an axis. See Also -------- numpy.ndarray.max Index.max : Return the maximum value in an Index. Series.max : Return the maximum value in a Series.
[ "Return", "the", "maximum", "value", "of", "the", "Array", "or", "maximum", "along", "an", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1405-L1435
train
pandas-dev/pandas
pandas/core/arrays/period.py
_period_array_cmp
def _period_array_cmp(cls, op): """ Wrap comparison operations to convert Period-like to PeriodDtype """ opname = '__{name}__'.format(name=op.__name__) nat_result = opname == '__ne__' def wrapper(self, other): op = getattr(self.asi8, opname) if isinstance(other, (ABCDataFrame, ...
python
def _period_array_cmp(cls, op): """ Wrap comparison operations to convert Period-like to PeriodDtype """ opname = '__{name}__'.format(name=op.__name__) nat_result = opname == '__ne__' def wrapper(self, other): op = getattr(self.asi8, opname) if isinstance(other, (ABCDataFrame, ...
[ "def", "_period_array_cmp", "(", "cls", ",", "op", ")", ":", "opname", "=", "'__{name}__'", ".", "format", "(", "name", "=", "op", ".", "__name__", ")", "nat_result", "=", "opname", "==", "'__ne__'", "def", "wrapper", "(", "self", ",", "other", ")", ":...
Wrap comparison operations to convert Period-like to PeriodDtype
[ "Wrap", "comparison", "operations", "to", "convert", "Period", "-", "like", "to", "PeriodDtype" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L44-L86
train
pandas-dev/pandas
pandas/core/arrays/period.py
_raise_on_incompatible
def _raise_on_incompatible(left, right): """ Helper function to render a consistent error message when raising IncompatibleFrequency. Parameters ---------- left : PeriodArray right : DateOffset, Period, ndarray, or timedelta-like Raises ------ IncompatibleFrequency """ ...
python
def _raise_on_incompatible(left, right): """ Helper function to render a consistent error message when raising IncompatibleFrequency. Parameters ---------- left : PeriodArray right : DateOffset, Period, ndarray, or timedelta-like Raises ------ IncompatibleFrequency """ ...
[ "def", "_raise_on_incompatible", "(", "left", ",", "right", ")", ":", "# GH#24283 error message format depends on whether right is scalar", "if", "isinstance", "(", "right", ",", "np", ".", "ndarray", ")", ":", "other_freq", "=", "None", "elif", "isinstance", "(", "...
Helper function to render a consistent error message when raising IncompatibleFrequency. Parameters ---------- left : PeriodArray right : DateOffset, Period, ndarray, or timedelta-like Raises ------ IncompatibleFrequency
[ "Helper", "function", "to", "render", "a", "consistent", "error", "message", "when", "raising", "IncompatibleFrequency", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L681-L706
train
pandas-dev/pandas
pandas/core/arrays/period.py
period_array
def period_array( data: Sequence[Optional[Period]], freq: Optional[Tick] = None, copy: bool = False, ) -> PeriodArray: """ Construct a new PeriodArray from a sequence of Period scalars. Parameters ---------- data : Sequence of Period objects A sequence of Period obje...
python
def period_array( data: Sequence[Optional[Period]], freq: Optional[Tick] = None, copy: bool = False, ) -> PeriodArray: """ Construct a new PeriodArray from a sequence of Period scalars. Parameters ---------- data : Sequence of Period objects A sequence of Period obje...
[ "def", "period_array", "(", "data", ":", "Sequence", "[", "Optional", "[", "Period", "]", "]", ",", "freq", ":", "Optional", "[", "Tick", "]", "=", "None", ",", "copy", ":", "bool", "=", "False", ",", ")", "->", "PeriodArray", ":", "if", "is_datetime...
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,...
[ "Construct", "a", "new", "PeriodArray", "from", "a", "sequence", "of", "Period", "scalars", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L712-L791
train
pandas-dev/pandas
pandas/core/arrays/period.py
validate_dtype_freq
def validate_dtype_freq(dtype, freq): """ 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 ------ ...
python
def validate_dtype_freq(dtype, freq): """ 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 ------ ...
[ "def", "validate_dtype_freq", "(", "dtype", ",", "freq", ")", ":", "if", "freq", "is", "not", "None", ":", "freq", "=", "frequencies", ".", "to_offset", "(", "freq", ")", "if", "dtype", "is", "not", "None", ":", "dtype", "=", "pandas_dtype", "(", "dtyp...
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 IncompatibleF...
[ "If", "both", "a", "dtype", "and", "a", "freq", "are", "available", "ensure", "they", "match", ".", "If", "only", "dtype", "is", "available", "extract", "the", "implied", "freq", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L794-L825
train
pandas-dev/pandas
pandas/core/arrays/period.py
dt64arr_to_periodarr
def dt64arr_to_periodarr(data, freq, tz=None): """ 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` i...
python
def dt64arr_to_periodarr(data, freq, tz=None): """ 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` i...
[ "def", "dt64arr_to_periodarr", "(", "data", ",", "freq", ",", "tz", "=", "None", ")", ":", "if", "data", ".", "dtype", "!=", "np", ".", "dtype", "(", "'M8[ns]'", ")", ":", "raise", "ValueError", "(", "'Wrong dtype: {dtype}'", ".", "format", "(", "dtype",...
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[tzin...
[ "Convert", "an", "datetime", "-", "like", "array", "to", "values", "Period", "ordinals", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L828-L863
train
pandas-dev/pandas
pandas/core/arrays/period.py
PeriodArray._from_datetime64
def _from_datetime64(cls, data, freq, tz=None): """ Construct a PeriodArray from a datetime64 array Parameters ---------- data : ndarray[datetime64[ns], datetime64[ns, tz]] freq : str or Tick tz : tzinfo, optional Returns ------- PeriodAr...
python
def _from_datetime64(cls, data, freq, tz=None): """ Construct a PeriodArray from a datetime64 array Parameters ---------- data : ndarray[datetime64[ns], datetime64[ns, tz]] freq : str or Tick tz : tzinfo, optional Returns ------- PeriodAr...
[ "def", "_from_datetime64", "(", "cls", ",", "data", ",", "freq", ",", "tz", "=", "None", ")", ":", "data", ",", "freq", "=", "dt64arr_to_periodarr", "(", "data", ",", "freq", ",", "tz", ")", "return", "cls", "(", "data", ",", "freq", "=", "freq", "...
Construct a PeriodArray from a datetime64 array Parameters ---------- data : ndarray[datetime64[ns], datetime64[ns, tz]] freq : str or Tick tz : tzinfo, optional Returns ------- PeriodArray[freq]
[ "Construct", "a", "PeriodArray", "from", "a", "datetime64", "array" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L211-L226
train
pandas-dev/pandas
pandas/core/arrays/period.py
PeriodArray.to_timestamp
def to_timestamp(self, freq=None, how='start'): """ Cast to DatetimeArray/Index. Parameters ---------- freq : string or DateOffset, optional Target frequency. The default is 'D' for week or longer, 'S' otherwise how : {'s', 'e', 'start', 'end'} ...
python
def to_timestamp(self, freq=None, how='start'): """ Cast to DatetimeArray/Index. Parameters ---------- freq : string or DateOffset, optional Target frequency. The default is 'D' for week or longer, 'S' otherwise how : {'s', 'e', 'start', 'end'} ...
[ "def", "to_timestamp", "(", "self", ",", "freq", "=", "None", ",", "how", "=", "'start'", ")", ":", "from", "pandas", ".", "core", ".", "arrays", "import", "DatetimeArray", "how", "=", "libperiod", ".", "_validate_end_alias", "(", "how", ")", "end", "=",...
Cast to DatetimeArray/Index. Parameters ---------- freq : string or DateOffset, optional Target frequency. The default is 'D' for week or longer, 'S' otherwise how : {'s', 'e', 'start', 'end'} Returns ------- DatetimeArray/Index
[ "Cast", "to", "DatetimeArray", "/", "Index", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L327-L366
train
pandas-dev/pandas
pandas/core/arrays/period.py
PeriodArray._time_shift
def _time_shift(self, periods, freq=None): """ Shift each value by `periods`. Note this is different from ExtensionArray.shift, which shifts the *position* of each element, padding the end with missing values. Parameters ---------- periods : int ...
python
def _time_shift(self, periods, freq=None): """ Shift each value by `periods`. Note this is different from ExtensionArray.shift, which shifts the *position* of each element, padding the end with missing values. Parameters ---------- periods : int ...
[ "def", "_time_shift", "(", "self", ",", "periods", ",", "freq", "=", "None", ")", ":", "if", "freq", "is", "not", "None", ":", "raise", "TypeError", "(", "\"`freq` argument is not supported for \"", "\"{cls}._time_shift\"", ".", "format", "(", "cls", "=", "typ...
Shift each value by `periods`. Note this is different from ExtensionArray.shift, which shifts the *position* of each element, padding the end with missing values. Parameters ---------- periods : int Number of periods to shift by. freq : pandas.DateOf...
[ "Shift", "each", "value", "by", "periods", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L390-L412
train
pandas-dev/pandas
pandas/core/arrays/period.py
PeriodArray.asfreq
def asfreq(self, freq=None, how='E'): """ Convert the Period Array/Index to the specified frequency `freq`. Parameters ---------- freq : str a frequency how : str {'E', 'S'} 'E', 'END', or 'FINISH' for end, 'S', 'START', or 'BEGIN' for...
python
def asfreq(self, freq=None, how='E'): """ Convert the Period Array/Index to the specified frequency `freq`. Parameters ---------- freq : str a frequency how : str {'E', 'S'} 'E', 'END', or 'FINISH' for end, 'S', 'START', or 'BEGIN' for...
[ "def", "asfreq", "(", "self", ",", "freq", "=", "None", ",", "how", "=", "'E'", ")", ":", "how", "=", "libperiod", ".", "_validate_end_alias", "(", "how", ")", "freq", "=", "Period", ".", "_maybe_convert_freq", "(", "freq", ")", "base1", ",", "mult1", ...
Convert the Period Array/Index to the specified frequency `freq`. Parameters ---------- freq : str a frequency how : str {'E', 'S'} 'E', 'END', or 'FINISH' for end, 'S', 'START', or 'BEGIN' for start. Whether the elements should be aligned...
[ "Convert", "the", "Period", "Array", "/", "Index", "to", "the", "specified", "frequency", "freq", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L418-L472
train
pandas-dev/pandas
pandas/core/arrays/period.py
PeriodArray._format_native_types
def _format_native_types(self, na_rep='NaT', date_format=None, **kwargs): """ actually format my specific types """ values = self.astype(object) if date_format: formatter = lambda dt: dt.strftime(date_format) else: formatter = lambda dt: '%s' % dt...
python
def _format_native_types(self, na_rep='NaT', date_format=None, **kwargs): """ actually format my specific types """ values = self.astype(object) if date_format: formatter = lambda dt: dt.strftime(date_format) else: formatter = lambda dt: '%s' % dt...
[ "def", "_format_native_types", "(", "self", ",", "na_rep", "=", "'NaT'", ",", "date_format", "=", "None", ",", "*", "*", "kwargs", ")", ":", "values", "=", "self", ".", "astype", "(", "object", ")", "if", "date_format", ":", "formatter", "=", "lambda", ...
actually format my specific types
[ "actually", "format", "my", "specific", "types" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L477-L496
train
pandas-dev/pandas
pandas/core/arrays/period.py
PeriodArray._add_timedeltalike_scalar
def _add_timedeltalike_scalar(self, other): """ Parameters ---------- other : timedelta, Tick, np.timedelta64 Returns ------- result : ndarray[int64] """ assert isinstance(self.freq, Tick) # checked by calling function assert isinstance(o...
python
def _add_timedeltalike_scalar(self, other): """ Parameters ---------- other : timedelta, Tick, np.timedelta64 Returns ------- result : ndarray[int64] """ assert isinstance(self.freq, Tick) # checked by calling function assert isinstance(o...
[ "def", "_add_timedeltalike_scalar", "(", "self", ",", "other", ")", ":", "assert", "isinstance", "(", "self", ".", "freq", ",", "Tick", ")", "# checked by calling function", "assert", "isinstance", "(", "other", ",", "(", "timedelta", ",", "np", ".", "timedelt...
Parameters ---------- other : timedelta, Tick, np.timedelta64 Returns ------- result : ndarray[int64]
[ "Parameters", "----------", "other", ":", "timedelta", "Tick", "np", ".", "timedelta64" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L565-L587
train
pandas-dev/pandas
pandas/core/arrays/period.py
PeriodArray._add_delta_tdi
def _add_delta_tdi(self, other): """ Parameters ---------- other : TimedeltaArray or ndarray[timedelta64] Returns ------- result : ndarray[int64] """ assert isinstance(self.freq, Tick) # checked by calling function delta = self._check_ti...
python
def _add_delta_tdi(self, other): """ Parameters ---------- other : TimedeltaArray or ndarray[timedelta64] Returns ------- result : ndarray[int64] """ assert isinstance(self.freq, Tick) # checked by calling function delta = self._check_ti...
[ "def", "_add_delta_tdi", "(", "self", ",", "other", ")", ":", "assert", "isinstance", "(", "self", ".", "freq", ",", "Tick", ")", "# checked by calling function", "delta", "=", "self", ".", "_check_timedeltalike_freq_compat", "(", "other", ")", "return", "self",...
Parameters ---------- other : TimedeltaArray or ndarray[timedelta64] Returns ------- result : ndarray[int64]
[ "Parameters", "----------", "other", ":", "TimedeltaArray", "or", "ndarray", "[", "timedelta64", "]" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L589-L602
train
pandas-dev/pandas
pandas/core/arrays/period.py
PeriodArray._add_delta
def _add_delta(self, other): """ Add a timedelta-like, Tick, or TimedeltaIndex-like object to self, yielding a new PeriodArray Parameters ---------- other : {timedelta, np.timedelta64, Tick, TimedeltaIndex, ndarray[timedelta64]} Returns ...
python
def _add_delta(self, other): """ Add a timedelta-like, Tick, or TimedeltaIndex-like object to self, yielding a new PeriodArray Parameters ---------- other : {timedelta, np.timedelta64, Tick, TimedeltaIndex, ndarray[timedelta64]} Returns ...
[ "def", "_add_delta", "(", "self", ",", "other", ")", ":", "if", "not", "isinstance", "(", "self", ".", "freq", ",", "Tick", ")", ":", "# We cannot add timedelta-like to non-tick PeriodArray", "_raise_on_incompatible", "(", "self", ",", "other", ")", "new_ordinals"...
Add a timedelta-like, Tick, or TimedeltaIndex-like object to self, yielding a new PeriodArray Parameters ---------- other : {timedelta, np.timedelta64, Tick, TimedeltaIndex, ndarray[timedelta64]} Returns ------- result : PeriodArray
[ "Add", "a", "timedelta", "-", "like", "Tick", "or", "TimedeltaIndex", "-", "like", "object", "to", "self", "yielding", "a", "new", "PeriodArray" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L604-L623
train
pandas-dev/pandas
pandas/core/arrays/period.py
PeriodArray._check_timedeltalike_freq_compat
def _check_timedeltalike_freq_compat(self, other): """ Arithmetic operations with timedelta-like scalars or array `other` are only valid if `other` is an integer multiple of `self.freq`. If the operation is valid, find that integer multiple. Otherwise, raise because the operatio...
python
def _check_timedeltalike_freq_compat(self, other): """ Arithmetic operations with timedelta-like scalars or array `other` are only valid if `other` is an integer multiple of `self.freq`. If the operation is valid, find that integer multiple. Otherwise, raise because the operatio...
[ "def", "_check_timedeltalike_freq_compat", "(", "self", ",", "other", ")", ":", "assert", "isinstance", "(", "self", ".", "freq", ",", "Tick", ")", "# checked by calling function", "own_offset", "=", "frequencies", ".", "to_offset", "(", "self", ".", "freq", "."...
Arithmetic operations with timedelta-like scalars or array `other` are only valid if `other` is an integer multiple of `self.freq`. If the operation is valid, find that integer multiple. Otherwise, raise because the operation is invalid. Parameters ---------- other : ti...
[ "Arithmetic", "operations", "with", "timedelta", "-", "like", "scalars", "or", "array", "other", "are", "only", "valid", "if", "other", "is", "an", "integer", "multiple", "of", "self", ".", "freq", ".", "If", "the", "operation", "is", "valid", "find", "tha...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L625-L672
train
pandas-dev/pandas
pandas/core/dtypes/missing.py
_isna_old
def _isna_old(obj): """Detect missing values. Treat None, NaN, INF, -INF as null. Parameters ---------- arr: ndarray or object value Returns ------- boolean ndarray or boolean """ if is_scalar(obj): return libmissing.checknull_old(obj) # hack (for now) because MI regist...
python
def _isna_old(obj): """Detect missing values. Treat None, NaN, INF, -INF as null. Parameters ---------- arr: ndarray or object value Returns ------- boolean ndarray or boolean """ if is_scalar(obj): return libmissing.checknull_old(obj) # hack (for now) because MI regist...
[ "def", "_isna_old", "(", "obj", ")", ":", "if", "is_scalar", "(", "obj", ")", ":", "return", "libmissing", ".", "checknull_old", "(", "obj", ")", "# hack (for now) because MI registers as ndarray", "elif", "isinstance", "(", "obj", ",", "ABCMultiIndex", ")", ":"...
Detect missing values. Treat None, NaN, INF, -INF as null. Parameters ---------- arr: ndarray or object value Returns ------- boolean ndarray or boolean
[ "Detect", "missing", "values", ".", "Treat", "None", "NaN", "INF", "-", "INF", "as", "null", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/missing.py#L126-L151
train
pandas-dev/pandas
pandas/core/dtypes/missing.py
_use_inf_as_na
def _use_inf_as_na(key): """Option change callback for na/inf behaviour Choose which replacement for numpy.isnan / -numpy.isfinite is used. Parameters ---------- flag: bool True means treat None, NaN, INF, -INF as null (old way), False means None and NaN are null, but INF, -INF are ...
python
def _use_inf_as_na(key): """Option change callback for na/inf behaviour Choose which replacement for numpy.isnan / -numpy.isfinite is used. Parameters ---------- flag: bool True means treat None, NaN, INF, -INF as null (old way), False means None and NaN are null, but INF, -INF are ...
[ "def", "_use_inf_as_na", "(", "key", ")", ":", "from", "pandas", ".", "_config", "import", "get_option", "flag", "=", "get_option", "(", "key", ")", "if", "flag", ":", "globals", "(", ")", "[", "'_isna'", "]", "=", "_isna_old", "else", ":", "globals", ...
Option change callback for na/inf behaviour Choose which replacement for numpy.isnan / -numpy.isfinite is used. Parameters ---------- flag: bool True means treat None, NaN, INF, -INF as null (old way), False means None and NaN are null, but INF, -INF are not null (new way). ...
[ "Option", "change", "callback", "for", "na", "/", "inf", "behaviour", "Choose", "which", "replacement", "for", "numpy", ".", "isnan", "/", "-", "numpy", ".", "isfinite", "is", "used", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/missing.py#L157-L181
train
pandas-dev/pandas
pandas/core/dtypes/missing.py
_isna_compat
def _isna_compat(arr, fill_value=np.nan): """ Parameters ---------- arr: a numpy array fill_value: fill value, default to np.nan Returns ------- True if we can fill using this fill_value """ dtype = arr.dtype if isna(fill_value): return not (is_bool_dtype(dtype) or ...
python
def _isna_compat(arr, fill_value=np.nan): """ Parameters ---------- arr: a numpy array fill_value: fill value, default to np.nan Returns ------- True if we can fill using this fill_value """ dtype = arr.dtype if isna(fill_value): return not (is_bool_dtype(dtype) or ...
[ "def", "_isna_compat", "(", "arr", ",", "fill_value", "=", "np", ".", "nan", ")", ":", "dtype", "=", "arr", ".", "dtype", "if", "isna", "(", "fill_value", ")", ":", "return", "not", "(", "is_bool_dtype", "(", "dtype", ")", "or", "is_integer_dtype", "("...
Parameters ---------- arr: a numpy array fill_value: fill value, default to np.nan Returns ------- True if we can fill using this fill_value
[ "Parameters", "----------", "arr", ":", "a", "numpy", "array", "fill_value", ":", "fill", "value", "default", "to", "np", ".", "nan" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/missing.py#L343-L358
train
pandas-dev/pandas
pandas/core/dtypes/missing.py
array_equivalent
def array_equivalent(left, right, strict_nan=False): """ True if two arrays, left and right, have equal non-NaN elements, and NaNs in corresponding locations. False otherwise. It is assumed that left and right are NumPy arrays of the same dtype. The behavior of this function (particularly with resp...
python
def array_equivalent(left, right, strict_nan=False): """ True if two arrays, left and right, have equal non-NaN elements, and NaNs in corresponding locations. False otherwise. It is assumed that left and right are NumPy arrays of the same dtype. The behavior of this function (particularly with resp...
[ "def", "array_equivalent", "(", "left", ",", "right", ",", "strict_nan", "=", "False", ")", ":", "left", ",", "right", "=", "np", ".", "asarray", "(", "left", ")", ",", "np", ".", "asarray", "(", "right", ")", "# shape compat", "if", "left", ".", "sh...
True if two arrays, left and right, have equal non-NaN elements, and NaNs in corresponding locations. False otherwise. It is assumed that left and right are NumPy arrays of the same dtype. The behavior of this function (particularly with respect to NaNs) is not defined if the dtypes are different. ...
[ "True", "if", "two", "arrays", "left", "and", "right", "have", "equal", "non", "-", "NaN", "elements", "and", "NaNs", "in", "corresponding", "locations", ".", "False", "otherwise", ".", "It", "is", "assumed", "that", "left", "and", "right", "are", "NumPy",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/missing.py#L361-L446
train
pandas-dev/pandas
pandas/core/dtypes/missing.py
_infer_fill_value
def _infer_fill_value(val): """ infer the fill value for the nan/NaT from the provided scalar/ndarray/list-like if we are a NaT, return the correct dtyped element to provide proper block construction """ if not is_list_like(val): val = [val] val = np.array(val, copy=False) if is...
python
def _infer_fill_value(val): """ infer the fill value for the nan/NaT from the provided scalar/ndarray/list-like if we are a NaT, return the correct dtyped element to provide proper block construction """ if not is_list_like(val): val = [val] val = np.array(val, copy=False) if is...
[ "def", "_infer_fill_value", "(", "val", ")", ":", "if", "not", "is_list_like", "(", "val", ")", ":", "val", "=", "[", "val", "]", "val", "=", "np", ".", "array", "(", "val", ",", "copy", "=", "False", ")", "if", "is_datetimelike", "(", "val", ")", ...
infer the fill value for the nan/NaT from the provided scalar/ndarray/list-like if we are a NaT, return the correct dtyped element to provide proper block construction
[ "infer", "the", "fill", "value", "for", "the", "nan", "/", "NaT", "from", "the", "provided", "scalar", "/", "ndarray", "/", "list", "-", "like", "if", "we", "are", "a", "NaT", "return", "the", "correct", "dtyped", "element", "to", "provide", "proper", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/missing.py#L449-L467
train
pandas-dev/pandas
pandas/core/dtypes/missing.py
_maybe_fill
def _maybe_fill(arr, fill_value=np.nan): """ if we have a compatible fill_value and arr dtype, then fill """ if _isna_compat(arr, fill_value): arr.fill(fill_value) return arr
python
def _maybe_fill(arr, fill_value=np.nan): """ if we have a compatible fill_value and arr dtype, then fill """ if _isna_compat(arr, fill_value): arr.fill(fill_value) return arr
[ "def", "_maybe_fill", "(", "arr", ",", "fill_value", "=", "np", ".", "nan", ")", ":", "if", "_isna_compat", "(", "arr", ",", "fill_value", ")", ":", "arr", ".", "fill", "(", "fill_value", ")", "return", "arr" ]
if we have a compatible fill_value and arr dtype, then fill
[ "if", "we", "have", "a", "compatible", "fill_value", "and", "arr", "dtype", "then", "fill" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/missing.py#L470-L476
train
pandas-dev/pandas
pandas/core/dtypes/missing.py
na_value_for_dtype
def na_value_for_dtype(dtype, compat=True): """ Return a dtype compat na value Parameters ---------- dtype : string / dtype compat : boolean, default True Returns ------- np.dtype or a pandas dtype Examples -------- >>> na_value_for_dtype(np.dtype('int64')) 0 >...
python
def na_value_for_dtype(dtype, compat=True): """ Return a dtype compat na value Parameters ---------- dtype : string / dtype compat : boolean, default True Returns ------- np.dtype or a pandas dtype Examples -------- >>> na_value_for_dtype(np.dtype('int64')) 0 >...
[ "def", "na_value_for_dtype", "(", "dtype", ",", "compat", "=", "True", ")", ":", "dtype", "=", "pandas_dtype", "(", "dtype", ")", "if", "is_extension_array_dtype", "(", "dtype", ")", ":", "return", "dtype", ".", "na_value", "if", "(", "is_datetime64_dtype", ...
Return a dtype compat na value Parameters ---------- dtype : string / dtype compat : boolean, default True Returns ------- np.dtype or a pandas dtype Examples -------- >>> na_value_for_dtype(np.dtype('int64')) 0 >>> na_value_for_dtype(np.dtype('int64'), compat=False) ...
[ "Return", "a", "dtype", "compat", "na", "value" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/missing.py#L479-L520
train
pandas-dev/pandas
pandas/core/dtypes/missing.py
remove_na_arraylike
def remove_na_arraylike(arr): """ Return array-like containing only true/non-NaN values, possibly empty. """ if is_extension_array_dtype(arr): return arr[notna(arr)] else: return arr[notna(lib.values_from_object(arr))]
python
def remove_na_arraylike(arr): """ Return array-like containing only true/non-NaN values, possibly empty. """ if is_extension_array_dtype(arr): return arr[notna(arr)] else: return arr[notna(lib.values_from_object(arr))]
[ "def", "remove_na_arraylike", "(", "arr", ")", ":", "if", "is_extension_array_dtype", "(", "arr", ")", ":", "return", "arr", "[", "notna", "(", "arr", ")", "]", "else", ":", "return", "arr", "[", "notna", "(", "lib", ".", "values_from_object", "(", "arr"...
Return array-like containing only true/non-NaN values, possibly empty.
[ "Return", "array", "-", "like", "containing", "only", "true", "/", "non", "-", "NaN", "values", "possibly", "empty", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/missing.py#L523-L530
train
pandas-dev/pandas
pandas/plotting/_tools.py
table
def table(ax, data, rowLabels=None, colLabels=None, **kwargs): """ Helper function to convert DataFrame and Series to matplotlib.table Parameters ---------- ax : Matplotlib axes object data : DataFrame or Series data for table contents kwargs : keywords, optional keyword arg...
python
def table(ax, data, rowLabels=None, colLabels=None, **kwargs): """ Helper function to convert DataFrame and Series to matplotlib.table Parameters ---------- ax : Matplotlib axes object data : DataFrame or Series data for table contents kwargs : keywords, optional keyword arg...
[ "def", "table", "(", "ax", ",", "data", ",", "rowLabels", "=", "None", ",", "colLabels", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "data", ",", "ABCSeries", ")", ":", "data", "=", "data", ".", "to_frame", "(", ")", ...
Helper function to convert DataFrame and Series to matplotlib.table Parameters ---------- ax : Matplotlib axes object data : DataFrame or Series data for table contents kwargs : keywords, optional keyword arguments which passed to matplotlib.table.table. If `rowLabels` or `c...
[ "Helper", "function", "to", "convert", "DataFrame", "and", "Series", "to", "matplotlib", ".", "table" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_tools.py#L23-L60
train
pandas-dev/pandas
pandas/plotting/_tools.py
_subplots
def _subplots(naxes=None, sharex=False, sharey=False, squeeze=True, subplot_kw=None, ax=None, layout=None, layout_type='box', **fig_kw): """Create a figure with a set of subplots already made. This utility wrapper makes it convenient to create common layouts of subplots, includi...
python
def _subplots(naxes=None, sharex=False, sharey=False, squeeze=True, subplot_kw=None, ax=None, layout=None, layout_type='box', **fig_kw): """Create a figure with a set of subplots already made. This utility wrapper makes it convenient to create common layouts of subplots, includi...
[ "def", "_subplots", "(", "naxes", "=", "None", ",", "sharex", "=", "False", ",", "sharey", "=", "False", ",", "squeeze", "=", "True", ",", "subplot_kw", "=", "None", ",", "ax", "=", "None", ",", "layout", "=", "None", ",", "layout_type", "=", "'box'"...
Create a figure with a set of subplots already made. This utility wrapper makes it convenient to create common layouts of subplots, including the enclosing figure object, in a single call. Keyword arguments: naxes : int Number of required axes. Exceeded axes are set invisible. Default is ...
[ "Create", "a", "figure", "with", "a", "set", "of", "subplots", "already", "made", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_tools.py#L110-L271
train
pandas-dev/pandas
setup.py
maybe_cythonize
def maybe_cythonize(extensions, *args, **kwargs): """ Render tempita templates before calling cythonize """ if len(sys.argv) > 1 and 'clean' in sys.argv: # Avoid running cythonize on `python setup.py clean` # See https://github.com/cython/cython/issues/1495 return extensions ...
python
def maybe_cythonize(extensions, *args, **kwargs): """ Render tempita templates before calling cythonize """ if len(sys.argv) > 1 and 'clean' in sys.argv: # Avoid running cythonize on `python setup.py clean` # See https://github.com/cython/cython/issues/1495 return extensions ...
[ "def", "maybe_cythonize", "(", "extensions", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "sys", ".", "argv", ")", ">", "1", "and", "'clean'", "in", "sys", ".", "argv", ":", "# Avoid running cythonize on `python setup.py clean`", ...
Render tempita templates before calling cythonize
[ "Render", "tempita", "templates", "before", "calling", "cythonize" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/setup.py#L490-L512
train
pandas-dev/pandas
pandas/core/groupby/generic.py
NDFrameGroupBy._transform_fast
def _transform_fast(self, result, obj, func_nm): """ Fast transform path for aggregations """ # if there were groups with no observations (Categorical only?) # try casting data to original dtype cast = self._transform_should_cast(func_nm) # for each col, reshape ...
python
def _transform_fast(self, result, obj, func_nm): """ Fast transform path for aggregations """ # if there were groups with no observations (Categorical only?) # try casting data to original dtype cast = self._transform_should_cast(func_nm) # for each col, reshape ...
[ "def", "_transform_fast", "(", "self", ",", "result", ",", "obj", ",", "func_nm", ")", ":", "# if there were groups with no observations (Categorical only?)", "# try casting data to original dtype", "cast", "=", "self", ".", "_transform_should_cast", "(", "func_nm", ")", ...
Fast transform path for aggregations
[ "Fast", "transform", "path", "for", "aggregations" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/generic.py#L526-L545
train
pandas-dev/pandas
pandas/core/groupby/generic.py
NDFrameGroupBy.filter
def filter(self, func, dropna=True, *args, **kwargs): # noqa """ Return a copy of a DataFrame excluding elements from groups that do not satisfy the boolean criterion specified by func. Parameters ---------- f : function Function to apply to each subframe. S...
python
def filter(self, func, dropna=True, *args, **kwargs): # noqa """ Return a copy of a DataFrame excluding elements from groups that do not satisfy the boolean criterion specified by func. Parameters ---------- f : function Function to apply to each subframe. S...
[ "def", "filter", "(", "self", ",", "func", ",", "dropna", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# noqa", "indices", "=", "[", "]", "obj", "=", "self", ".", "_selected_obj", "gen", "=", "self", ".", "grouper", ".", "ge...
Return a copy of a DataFrame excluding elements from groups that do not satisfy the boolean criterion specified by func. Parameters ---------- f : function Function to apply to each subframe. Should return True or False. dropna : Drop groups that do not pass the filt...
[ "Return", "a", "copy", "of", "a", "DataFrame", "excluding", "elements", "from", "groups", "that", "do", "not", "satisfy", "the", "boolean", "criterion", "specified", "by", "func", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/generic.py#L601-L661
train
pandas-dev/pandas
pandas/core/groupby/generic.py
SeriesGroupBy._wrap_output
def _wrap_output(self, output, index, names=None): """ common agg/transform wrapping logic """ output = output[self._selection_name] if names is not None: return DataFrame(output, index=index, columns=names) else: name = self._selection_name if name i...
python
def _wrap_output(self, output, index, names=None): """ common agg/transform wrapping logic """ output = output[self._selection_name] if names is not None: return DataFrame(output, index=index, columns=names) else: name = self._selection_name if name i...
[ "def", "_wrap_output", "(", "self", ",", "output", ",", "index", ",", "names", "=", "None", ")", ":", "output", "=", "output", "[", "self", ".", "_selection_name", "]", "if", "names", "is", "not", "None", ":", "return", "DataFrame", "(", "output", ",",...
common agg/transform wrapping logic
[ "common", "agg", "/", "transform", "wrapping", "logic" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/generic.py#L825-L835
train
pandas-dev/pandas
pandas/core/groupby/generic.py
SeriesGroupBy._transform_fast
def _transform_fast(self, func, func_nm): """ fast version of transform, only applicable to builtin/cythonizable functions """ if isinstance(func, str): func = getattr(self, func) ids, _, ngroup = self.grouper.group_info cast = self._transform_should_...
python
def _transform_fast(self, func, func_nm): """ fast version of transform, only applicable to builtin/cythonizable functions """ if isinstance(func, str): func = getattr(self, func) ids, _, ngroup = self.grouper.group_info cast = self._transform_should_...
[ "def", "_transform_fast", "(", "self", ",", "func", ",", "func_nm", ")", ":", "if", "isinstance", "(", "func", ",", "str", ")", ":", "func", "=", "getattr", "(", "self", ",", "func", ")", "ids", ",", "_", ",", "ngroup", "=", "self", ".", "grouper",...
fast version of transform, only applicable to builtin/cythonizable functions
[ "fast", "version", "of", "transform", "only", "applicable", "to", "builtin", "/", "cythonizable", "functions" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/generic.py#L934-L947
train
pandas-dev/pandas
pandas/core/groupby/generic.py
SeriesGroupBy.filter
def filter(self, func, dropna=True, *args, **kwargs): # noqa """ Return a copy of a Series excluding elements from groups that do not satisfy the boolean criterion specified by func. Parameters ---------- func : function To apply to each group. Should return...
python
def filter(self, func, dropna=True, *args, **kwargs): # noqa """ Return a copy of a Series excluding elements from groups that do not satisfy the boolean criterion specified by func. Parameters ---------- func : function To apply to each group. Should return...
[ "def", "filter", "(", "self", ",", "func", ",", "dropna", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# noqa", "if", "isinstance", "(", "func", ",", "str", ")", ":", "wrapper", "=", "lambda", "x", ":", "getattr", "(", "x", ...
Return a copy of a Series excluding elements from groups that do not satisfy the boolean criterion specified by func. Parameters ---------- func : function To apply to each group. Should return True or False. dropna : Drop groups that do not pass the filter. True by ...
[ "Return", "a", "copy", "of", "a", "Series", "excluding", "elements", "from", "groups", "that", "do", "not", "satisfy", "the", "boolean", "criterion", "specified", "by", "func", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/generic.py#L949-L997
train
pandas-dev/pandas
pandas/core/groupby/generic.py
SeriesGroupBy.nunique
def nunique(self, dropna=True): """ Return number of unique elements in the group. """ ids, _, _ = self.grouper.group_info val = self.obj.get_values() try: sorter = np.lexsort((val, ids)) except TypeError: # catches object dtypes msg = '...
python
def nunique(self, dropna=True): """ Return number of unique elements in the group. """ ids, _, _ = self.grouper.group_info val = self.obj.get_values() try: sorter = np.lexsort((val, ids)) except TypeError: # catches object dtypes msg = '...
[ "def", "nunique", "(", "self", ",", "dropna", "=", "True", ")", ":", "ids", ",", "_", ",", "_", "=", "self", ".", "grouper", ".", "group_info", "val", "=", "self", ".", "obj", ".", "get_values", "(", ")", "try", ":", "sorter", "=", "np", ".", "...
Return number of unique elements in the group.
[ "Return", "number", "of", "unique", "elements", "in", "the", "group", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/generic.py#L999-L1054
train
pandas-dev/pandas
pandas/core/groupby/generic.py
SeriesGroupBy.count
def count(self): """ Compute count of group, excluding missing values """ ids, _, ngroups = self.grouper.group_info val = self.obj.get_values() mask = (ids != -1) & ~isna(val) ids = ensure_platform_int(ids) minlength = ngroups or 0 out = np.bincount(ids[mask], mi...
python
def count(self): """ Compute count of group, excluding missing values """ ids, _, ngroups = self.grouper.group_info val = self.obj.get_values() mask = (ids != -1) & ~isna(val) ids = ensure_platform_int(ids) minlength = ngroups or 0 out = np.bincount(ids[mask], mi...
[ "def", "count", "(", "self", ")", ":", "ids", ",", "_", ",", "ngroups", "=", "self", ".", "grouper", ".", "group_info", "val", "=", "self", ".", "obj", ".", "get_values", "(", ")", "mask", "=", "(", "ids", "!=", "-", "1", ")", "&", "~", "isna",...
Compute count of group, excluding missing values
[ "Compute", "count", "of", "group", "excluding", "missing", "values" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/generic.py#L1183-L1196
train
pandas-dev/pandas
pandas/core/groupby/generic.py
SeriesGroupBy.pct_change
def pct_change(self, periods=1, fill_method='pad', limit=None, freq=None): """Calcuate pct_change of each value to previous entry in group""" # TODO: Remove this conditional when #23918 is fixed if freq: return self.apply(lambda x: x.pct_change(periods=periods, ...
python
def pct_change(self, periods=1, fill_method='pad', limit=None, freq=None): """Calcuate pct_change of each value to previous entry in group""" # TODO: Remove this conditional when #23918 is fixed if freq: return self.apply(lambda x: x.pct_change(periods=periods, ...
[ "def", "pct_change", "(", "self", ",", "periods", "=", "1", ",", "fill_method", "=", "'pad'", ",", "limit", "=", "None", ",", "freq", "=", "None", ")", ":", "# TODO: Remove this conditional when #23918 is fixed", "if", "freq", ":", "return", "self", ".", "ap...
Calcuate pct_change of each value to previous entry in group
[ "Calcuate", "pct_change", "of", "each", "value", "to", "previous", "entry", "in", "group" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/generic.py#L1202-L1213
train
pandas-dev/pandas
pandas/core/groupby/generic.py
DataFrameGroupBy._gotitem
def _gotitem(self, key, ndim, subset=None): """ sub-classes to define return a sliced object Parameters ---------- key : string / list of selections ndim : 1,2 requested ndim of result subset : object, default None subset to act on...
python
def _gotitem(self, key, ndim, subset=None): """ sub-classes to define return a sliced object Parameters ---------- key : string / list of selections ndim : 1,2 requested ndim of result subset : object, default None subset to act on...
[ "def", "_gotitem", "(", "self", ",", "key", ",", "ndim", ",", "subset", "=", "None", ")", ":", "if", "ndim", "==", "2", ":", "if", "subset", "is", "None", ":", "subset", "=", "self", ".", "obj", "return", "DataFrameGroupBy", "(", "subset", ",", "se...
sub-classes to define return a sliced object Parameters ---------- key : string / list of selections ndim : 1,2 requested ndim of result subset : object, default None subset to act on
[ "sub", "-", "classes", "to", "define", "return", "a", "sliced", "object" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/generic.py#L1297-L1325
train
pandas-dev/pandas
pandas/core/groupby/generic.py
DataFrameGroupBy._reindex_output
def _reindex_output(self, result): """ If we have categorical groupers, then we want to make sure that we have a fully reindex-output to the levels. These may have not participated in the groupings (e.g. may have all been nan groups); This can re-expand the output space ...
python
def _reindex_output(self, result): """ If we have categorical groupers, then we want to make sure that we have a fully reindex-output to the levels. These may have not participated in the groupings (e.g. may have all been nan groups); This can re-expand the output space ...
[ "def", "_reindex_output", "(", "self", ",", "result", ")", ":", "# we need to re-expand the output space to accomodate all values", "# whether observed or not in the cartesian product of our groupes", "groupings", "=", "self", ".", "grouper", ".", "groupings", "if", "groupings", ...
If we have categorical groupers, then we want to make sure that we have a fully reindex-output to the levels. These may have not participated in the groupings (e.g. may have all been nan groups); This can re-expand the output space
[ "If", "we", "have", "categorical", "groupers", "then", "we", "want", "to", "make", "sure", "that", "we", "have", "a", "fully", "reindex", "-", "output", "to", "the", "levels", ".", "These", "may", "have", "not", "participated", "in", "the", "groupings", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/generic.py#L1395-L1456
train
pandas-dev/pandas
pandas/core/groupby/generic.py
DataFrameGroupBy._fill
def _fill(self, direction, limit=None): """Overridden method to join grouped columns in output""" res = super()._fill(direction, limit=limit) output = OrderedDict( (grp.name, grp.grouper) for grp in self.grouper.groupings) from pandas import concat return concat((sel...
python
def _fill(self, direction, limit=None): """Overridden method to join grouped columns in output""" res = super()._fill(direction, limit=limit) output = OrderedDict( (grp.name, grp.grouper) for grp in self.grouper.groupings) from pandas import concat return concat((sel...
[ "def", "_fill", "(", "self", ",", "direction", ",", "limit", "=", "None", ")", ":", "res", "=", "super", "(", ")", ".", "_fill", "(", "direction", ",", "limit", "=", "limit", ")", "output", "=", "OrderedDict", "(", "(", "grp", ".", "name", ",", "...
Overridden method to join grouped columns in output
[ "Overridden", "method", "to", "join", "grouped", "columns", "in", "output" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/generic.py#L1472-L1479
train
pandas-dev/pandas
pandas/core/groupby/generic.py
DataFrameGroupBy.count
def count(self): """ Compute count of group, excluding missing values """ from pandas.core.dtypes.missing import _isna_ndarraylike as _isna data, _ = self._get_data_to_aggregate() ids, _, ngroups = self.grouper.group_info mask = ids != -1 val = ((mask & ~_isna(np.atleas...
python
def count(self): """ Compute count of group, excluding missing values """ from pandas.core.dtypes.missing import _isna_ndarraylike as _isna data, _ = self._get_data_to_aggregate() ids, _, ngroups = self.grouper.group_info mask = ids != -1 val = ((mask & ~_isna(np.atleas...
[ "def", "count", "(", "self", ")", ":", "from", "pandas", ".", "core", ".", "dtypes", ".", "missing", "import", "_isna_ndarraylike", "as", "_isna", "data", ",", "_", "=", "self", ".", "_get_data_to_aggregate", "(", ")", "ids", ",", "_", ",", "ngroups", ...
Compute count of group, excluding missing values
[ "Compute", "count", "of", "group", "excluding", "missing", "values" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/generic.py#L1481-L1497
train
pandas-dev/pandas
pandas/core/groupby/generic.py
DataFrameGroupBy.nunique
def nunique(self, dropna=True): """ Return DataFrame with number of distinct observations per group for each column. .. versionadded:: 0.20.0 Parameters ---------- dropna : boolean, default True Don't include NaN in the counts. Returns ...
python
def nunique(self, dropna=True): """ Return DataFrame with number of distinct observations per group for each column. .. versionadded:: 0.20.0 Parameters ---------- dropna : boolean, default True Don't include NaN in the counts. Returns ...
[ "def", "nunique", "(", "self", ",", "dropna", "=", "True", ")", ":", "obj", "=", "self", ".", "_selected_obj", "def", "groupby_series", "(", "obj", ",", "col", "=", "None", ")", ":", "return", "SeriesGroupBy", "(", "obj", ",", "selection", "=", "col", ...
Return DataFrame with number of distinct observations per group for each column. .. versionadded:: 0.20.0 Parameters ---------- dropna : boolean, default True Don't include NaN in the counts. Returns ------- nunique: DataFrame Examp...
[ "Return", "DataFrame", "with", "number", "of", "distinct", "observations", "per", "group", "for", "each", "column", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/generic.py#L1499-L1564
train
pandas-dev/pandas
pandas/core/internals/arrays.py
extract_array
def extract_array(obj, extract_numpy=False): """ Extract the ndarray or ExtensionArray from a Series or Index. For all other types, `obj` is just returned as is. Parameters ---------- obj : object For Series / Index, the underlying ExtensionArray is unboxed. For Numpy-backed Ex...
python
def extract_array(obj, extract_numpy=False): """ Extract the ndarray or ExtensionArray from a Series or Index. For all other types, `obj` is just returned as is. Parameters ---------- obj : object For Series / Index, the underlying ExtensionArray is unboxed. For Numpy-backed Ex...
[ "def", "extract_array", "(", "obj", ",", "extract_numpy", "=", "False", ")", ":", "if", "isinstance", "(", "obj", ",", "(", "ABCIndexClass", ",", "ABCSeries", ")", ")", ":", "obj", "=", "obj", ".", "array", "if", "extract_numpy", "and", "isinstance", "("...
Extract the ndarray or ExtensionArray from a Series or Index. For all other types, `obj` is just returned as is. Parameters ---------- obj : object For Series / Index, the underlying ExtensionArray is unboxed. For Numpy-backed ExtensionArrays, the ndarray is extracted. extract_num...
[ "Extract", "the", "ndarray", "or", "ExtensionArray", "from", "a", "Series", "or", "Index", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/arrays.py#L7-L55
train
pandas-dev/pandas
pandas/core/common.py
flatten
def flatten(l): """ Flatten an arbitrarily nested sequence. Parameters ---------- l : sequence The non string sequence to flatten Notes ----- This doesn't consider strings sequences. Returns ------- flattened : generator """ for el in l: if _iterabl...
python
def flatten(l): """ Flatten an arbitrarily nested sequence. Parameters ---------- l : sequence The non string sequence to flatten Notes ----- This doesn't consider strings sequences. Returns ------- flattened : generator """ for el in l: if _iterabl...
[ "def", "flatten", "(", "l", ")", ":", "for", "el", "in", "l", ":", "if", "_iterable_not_string", "(", "el", ")", ":", "for", "s", "in", "flatten", "(", "el", ")", ":", "yield", "s", "else", ":", "yield", "el" ]
Flatten an arbitrarily nested sequence. Parameters ---------- l : sequence The non string sequence to flatten Notes ----- This doesn't consider strings sequences. Returns ------- flattened : generator
[ "Flatten", "an", "arbitrarily", "nested", "sequence", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/common.py#L35-L57
train
pandas-dev/pandas
pandas/core/common.py
is_bool_indexer
def is_bool_indexer(key: Any) -> bool: """ 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 Exte...
python
def is_bool_indexer(key: Any) -> bool: """ 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 Exte...
[ "def", "is_bool_indexer", "(", "key", ":", "Any", ")", "->", "bool", ":", "na_msg", "=", "'cannot index with vector containing NA / NaN values'", "if", "(", "isinstance", "(", "key", ",", "(", "ABCSeries", ",", "np", ".", "ndarray", ",", "ABCIndex", ")", ")", ...
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 co...
[ "Check", "whether", "key", "is", "a", "valid", "boolean", "indexer", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/common.py#L95-L142
train
pandas-dev/pandas
pandas/core/common.py
cast_scalar_indexer
def cast_scalar_indexer(val): """ To avoid numpy DeprecationWarnings, cast float to integer where valid. Parameters ---------- val : scalar Returns ------- outval : scalar """ # assumes lib.is_scalar(val) if lib.is_float(val) and val == int(val): return int(val) ...
python
def cast_scalar_indexer(val): """ To avoid numpy DeprecationWarnings, cast float to integer where valid. Parameters ---------- val : scalar Returns ------- outval : scalar """ # assumes lib.is_scalar(val) if lib.is_float(val) and val == int(val): return int(val) ...
[ "def", "cast_scalar_indexer", "(", "val", ")", ":", "# assumes lib.is_scalar(val)", "if", "lib", ".", "is_float", "(", "val", ")", "and", "val", "==", "int", "(", "val", ")", ":", "return", "int", "(", "val", ")", "return", "val" ]
To avoid numpy DeprecationWarnings, cast float to integer where valid. Parameters ---------- val : scalar Returns ------- outval : scalar
[ "To", "avoid", "numpy", "DeprecationWarnings", "cast", "float", "to", "integer", "where", "valid", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/common.py#L145-L160
train
pandas-dev/pandas
pandas/core/common.py
index_labels_to_array
def index_labels_to_array(labels, dtype=None): """ 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 """ if isinstance(labels, (...
python
def index_labels_to_array(labels, dtype=None): """ 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 """ if isinstance(labels, (...
[ "def", "index_labels_to_array", "(", "labels", ",", "dtype", "=", "None", ")", ":", "if", "isinstance", "(", "labels", ",", "(", "str", ",", "tuple", ")", ")", ":", "labels", "=", "[", "labels", "]", "if", "not", "isinstance", "(", "labels", ",", "("...
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
[ "Transform", "label", "or", "iterable", "of", "labels", "to", "array", "for", "use", "in", "Index", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/common.py#L259-L283
train
pandas-dev/pandas
pandas/core/common.py
is_null_slice
def is_null_slice(obj): """ We have a null slice. """ return (isinstance(obj, slice) and obj.start is None and obj.stop is None and obj.step is None)
python
def is_null_slice(obj): """ We have a null slice. """ return (isinstance(obj, slice) and obj.start is None and obj.stop is None and obj.step is None)
[ "def", "is_null_slice", "(", "obj", ")", ":", "return", "(", "isinstance", "(", "obj", ",", "slice", ")", "and", "obj", ".", "start", "is", "None", "and", "obj", ".", "stop", "is", "None", "and", "obj", ".", "step", "is", "None", ")" ]
We have a null slice.
[ "We", "have", "a", "null", "slice", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/common.py#L292-L297
train
pandas-dev/pandas
pandas/core/common.py
is_full_slice
def is_full_slice(obj, l): """ We have a full length slice. """ return (isinstance(obj, slice) and obj.start == 0 and obj.stop == l and obj.step is None)
python
def is_full_slice(obj, l): """ We have a full length slice. """ return (isinstance(obj, slice) and obj.start == 0 and obj.stop == l and obj.step is None)
[ "def", "is_full_slice", "(", "obj", ",", "l", ")", ":", "return", "(", "isinstance", "(", "obj", ",", "slice", ")", "and", "obj", ".", "start", "==", "0", "and", "obj", ".", "stop", "==", "l", "and", "obj", ".", "step", "is", "None", ")" ]
We have a full length slice.
[ "We", "have", "a", "full", "length", "slice", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/common.py#L308-L313
train
pandas-dev/pandas
pandas/core/common.py
apply_if_callable
def apply_if_callable(maybe_callable, obj, **kwargs): """ 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 """ if callable(maybe_callable): ...
python
def apply_if_callable(maybe_callable, obj, **kwargs): """ 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 """ if callable(maybe_callable): ...
[ "def", "apply_if_callable", "(", "maybe_callable", ",", "obj", ",", "*", "*", "kwargs", ")", ":", "if", "callable", "(", "maybe_callable", ")", ":", "return", "maybe_callable", "(", "obj", ",", "*", "*", "kwargs", ")", "return", "maybe_callable" ]
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
[ "Evaluate", "possibly", "callable", "input", "using", "obj", "and", "kwargs", "if", "it", "is", "callable", "otherwise", "return", "as", "it", "is", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/common.py#L333-L348
train
pandas-dev/pandas
pandas/core/common.py
standardize_mapping
def standardize_mapping(into): """ Helper function to standardize a supplied mapping. .. versionadded:: 0.21.0 Parameters ---------- into : instance or subclass of collections.abc.Mapping Must be a class, an initialized collections.defaultdict, or an instance of a collections.a...
python
def standardize_mapping(into): """ Helper function to standardize a supplied mapping. .. versionadded:: 0.21.0 Parameters ---------- into : instance or subclass of collections.abc.Mapping Must be a class, an initialized collections.defaultdict, or an instance of a collections.a...
[ "def", "standardize_mapping", "(", "into", ")", ":", "if", "not", "inspect", ".", "isclass", "(", "into", ")", ":", "if", "isinstance", "(", "into", ",", "collections", ".", "defaultdict", ")", ":", "return", "partial", "(", "collections", ".", "defaultdic...
Helper function to standardize a supplied mapping. .. versionadded:: 0.21.0 Parameters ---------- into : instance or subclass of collections.abc.Mapping Must be a class, an initialized collections.defaultdict, or an instance of a collections.abc.Mapping subclass. Returns -----...
[ "Helper", "function", "to", "standardize", "a", "supplied", "mapping", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/common.py#L368-L401
train
pandas-dev/pandas
pandas/core/common.py
random_state
def random_state(state=None): """ Helper function for processing random_state arguments. Parameters ---------- state : int, np.random.RandomState, None. If receives an int, passes to np.random.RandomState() as seed. If receives an np.random.RandomState object, just returns object. ...
python
def random_state(state=None): """ Helper function for processing random_state arguments. Parameters ---------- state : int, np.random.RandomState, None. If receives an int, passes to np.random.RandomState() as seed. If receives an np.random.RandomState object, just returns object. ...
[ "def", "random_state", "(", "state", "=", "None", ")", ":", "if", "is_integer", "(", "state", ")", ":", "return", "np", ".", "random", ".", "RandomState", "(", "state", ")", "elif", "isinstance", "(", "state", ",", "np", ".", "random", ".", "RandomStat...
Helper function for processing random_state arguments. Parameters ---------- state : int, np.random.RandomState, None. If receives an int, passes to np.random.RandomState() as seed. If receives an np.random.RandomState object, just returns object. If receives `None`, returns np.rand...
[ "Helper", "function", "for", "processing", "random_state", "arguments", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/common.py#L404-L430
train
pandas-dev/pandas
pandas/core/common.py
_pipe
def _pipe(obj, func, *args, **kwargs): """ 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 ...
python
def _pipe(obj, func, *args, **kwargs): """ 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 ...
[ "def", "_pipe", "(", "obj", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "func", ",", "tuple", ")", ":", "func", ",", "target", "=", "func", "if", "target", "in", "kwargs", ":", "msg", "=", "'%s is bo...
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...
[ "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", "elem...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/common.py#L433-L465
train
pandas-dev/pandas
pandas/core/common.py
_get_rename_function
def _get_rename_function(mapper): """ Returns a function that will map names/labels, dependent if mapper is a dict, Series or just a function. """ if isinstance(mapper, (abc.Mapping, ABCSeries)): def f(x): if x in mapper: return mapper[x] else: ...
python
def _get_rename_function(mapper): """ Returns a function that will map names/labels, dependent if mapper is a dict, Series or just a function. """ if isinstance(mapper, (abc.Mapping, ABCSeries)): def f(x): if x in mapper: return mapper[x] else: ...
[ "def", "_get_rename_function", "(", "mapper", ")", ":", "if", "isinstance", "(", "mapper", ",", "(", "abc", ".", "Mapping", ",", "ABCSeries", ")", ")", ":", "def", "f", "(", "x", ")", ":", "if", "x", "in", "mapper", ":", "return", "mapper", "[", "x...
Returns a function that will map names/labels, dependent if mapper is a dict, Series or just a function.
[ "Returns", "a", "function", "that", "will", "map", "names", "/", "labels", "dependent", "if", "mapper", "is", "a", "dict", "Series", "or", "just", "a", "function", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/common.py#L468-L483
train
pandas-dev/pandas
pandas/core/nanops.py
_get_fill_value
def _get_fill_value(dtype, fill_value=None, fill_value_typ=None): """ return the correct fill value for the dtype of the values """ if fill_value is not None: return fill_value if _na_ok_dtype(dtype): if fill_value_typ is None: return np.nan else: if fill_valu...
python
def _get_fill_value(dtype, fill_value=None, fill_value_typ=None): """ return the correct fill value for the dtype of the values """ if fill_value is not None: return fill_value if _na_ok_dtype(dtype): if fill_value_typ is None: return np.nan else: if fill_valu...
[ "def", "_get_fill_value", "(", "dtype", ",", "fill_value", "=", "None", ",", "fill_value_typ", "=", "None", ")", ":", "if", "fill_value", "is", "not", "None", ":", "return", "fill_value", "if", "_na_ok_dtype", "(", "dtype", ")", ":", "if", "fill_value_typ", ...
return the correct fill value for the dtype of the values
[ "return", "the", "correct", "fill", "value", "for", "the", "dtype", "of", "the", "values" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/nanops.py#L180-L200
train
pandas-dev/pandas
pandas/core/nanops.py
_get_values
def _get_values(values, skipna, fill_value=None, fill_value_typ=None, isfinite=False, copy=True, mask=None): """ utility to get the values view, mask, dtype if necessary copy and mask using the specified fill_value copy = True will force the copy """ if is_datetime64tz_dtype(values)...
python
def _get_values(values, skipna, fill_value=None, fill_value_typ=None, isfinite=False, copy=True, mask=None): """ utility to get the values view, mask, dtype if necessary copy and mask using the specified fill_value copy = True will force the copy """ if is_datetime64tz_dtype(values)...
[ "def", "_get_values", "(", "values", ",", "skipna", ",", "fill_value", "=", "None", ",", "fill_value_typ", "=", "None", ",", "isfinite", "=", "False", ",", "copy", "=", "True", ",", "mask", "=", "None", ")", ":", "if", "is_datetime64tz_dtype", "(", "valu...
utility to get the values view, mask, dtype if necessary copy and mask using the specified fill_value copy = True will force the copy
[ "utility", "to", "get", "the", "values", "view", "mask", "dtype", "if", "necessary", "copy", "and", "mask", "using", "the", "specified", "fill_value", "copy", "=", "True", "will", "force", "the", "copy" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/nanops.py#L203-L258
train
pandas-dev/pandas
pandas/core/nanops.py
_wrap_results
def _wrap_results(result, dtype, fill_value=None): """ wrap our results if needed """ if is_datetime64_dtype(dtype) or is_datetime64tz_dtype(dtype): if fill_value is None: # GH#24293 fill_value = iNaT if not isinstance(result, np.ndarray): tz = getattr(dtype,...
python
def _wrap_results(result, dtype, fill_value=None): """ wrap our results if needed """ if is_datetime64_dtype(dtype) or is_datetime64tz_dtype(dtype): if fill_value is None: # GH#24293 fill_value = iNaT if not isinstance(result, np.ndarray): tz = getattr(dtype,...
[ "def", "_wrap_results", "(", "result", ",", "dtype", ",", "fill_value", "=", "None", ")", ":", "if", "is_datetime64_dtype", "(", "dtype", ")", "or", "is_datetime64tz_dtype", "(", "dtype", ")", ":", "if", "fill_value", "is", "None", ":", "# GH#24293", "fill_v...
wrap our results if needed
[ "wrap", "our", "results", "if", "needed" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/nanops.py#L276-L304
train
pandas-dev/pandas
pandas/core/nanops.py
_na_for_min_count
def _na_for_min_count(values, axis): """Return the missing value for `values` Parameters ---------- values : ndarray axis : int or None axis for the reduction Returns ------- result : scalar or ndarray For 1-D values, returns a scalar of the correct missing type. ...
python
def _na_for_min_count(values, axis): """Return the missing value for `values` Parameters ---------- values : ndarray axis : int or None axis for the reduction Returns ------- result : scalar or ndarray For 1-D values, returns a scalar of the correct missing type. ...
[ "def", "_na_for_min_count", "(", "values", ",", "axis", ")", ":", "# we either return np.nan or pd.NaT", "if", "is_numeric_dtype", "(", "values", ")", ":", "values", "=", "values", ".", "astype", "(", "'float64'", ")", "fill_value", "=", "na_value_for_dtype", "(",...
Return the missing value for `values` Parameters ---------- values : ndarray axis : int or None axis for the reduction 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 ...
[ "Return", "the", "missing", "value", "for", "values" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/nanops.py#L307-L334
train
pandas-dev/pandas
pandas/core/nanops.py
nanany
def nanany(values, axis=None, skipna=True, mask=None): """ 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 ------- ...
python
def nanany(values, axis=None, skipna=True, mask=None): """ 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 ------- ...
[ "def", "nanany", "(", "values", ",", "axis", "=", "None", ",", "skipna", "=", "True", ",", "mask", "=", "None", ")", ":", "values", ",", "mask", ",", "dtype", ",", "_", ",", "_", "=", "_get_values", "(", "values", ",", "skipna", ",", "False", ","...
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 -------- >>> import pandas.core...
[ "Check", "if", "any", "elements", "along", "an", "axis", "evaluate", "to", "True", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/nanops.py#L337-L367
train
pandas-dev/pandas
pandas/core/nanops.py
nanall
def nanall(values, axis=None, skipna=True, mask=None): """ 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 ------- r...
python
def nanall(values, axis=None, skipna=True, mask=None): """ 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 ------- r...
[ "def", "nanall", "(", "values", ",", "axis", "=", "None", ",", "skipna", "=", "True", ",", "mask", "=", "None", ")", ":", "values", ",", "mask", ",", "dtype", ",", "_", ",", "_", "=", "_get_values", "(", "values", ",", "skipna", ",", "True", ",",...
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 -------- >>> import pandas.core....
[ "Check", "if", "all", "elements", "along", "an", "axis", "evaluate", "to", "True", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/nanops.py#L370-L400
train
pandas-dev/pandas
pandas/core/nanops.py
nansum
def nansum(values, axis=None, skipna=True, min_count=0, mask=None): """ 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-mas...
python
def nansum(values, axis=None, skipna=True, min_count=0, mask=None): """ 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-mas...
[ "def", "nansum", "(", "values", ",", "axis", "=", "None", ",", "skipna", "=", "True", ",", "min_count", "=", "0", ",", "mask", "=", "None", ")", ":", "values", ",", "mask", ",", "dtype", ",", "dtype_max", ",", "_", "=", "_get_values", "(", "values"...
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 -------...
[ "Sum", "the", "elements", "along", "an", "axis", "ignoring", "NaNs" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/nanops.py#L404-L438
train
pandas-dev/pandas
pandas/core/nanops.py
nanmean
def nanmean(values, axis=None, skipna=True, mask=None): """ 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 ------...
python
def nanmean(values, axis=None, skipna=True, mask=None): """ 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 ------...
[ "def", "nanmean", "(", "values", ",", "axis", "=", "None", ",", "skipna", "=", "True", ",", "mask", "=", "None", ")", ":", "values", ",", "mask", ",", "dtype", ",", "dtype_max", ",", "_", "=", "_get_values", "(", "values", ",", "skipna", ",", "0", ...
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 ------- result : float Unless input is a float array, in which...
[ "Compute", "the", "mean", "of", "the", "element", "along", "an", "axis", "ignoring", "NaNs" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/nanops.py#L443-L491
train
pandas-dev/pandas
pandas/core/nanops.py
nanmedian
def nanmedian(values, axis=None, skipna=True, mask=None): """ 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 ...
python
def nanmedian(values, axis=None, skipna=True, mask=None): """ 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 ...
[ "def", "nanmedian", "(", "values", ",", "axis", "=", "None", ",", "skipna", "=", "True", ",", "mask", "=", "None", ")", ":", "def", "get_median", "(", "x", ")", ":", "mask", "=", "notna", "(", "x", ")", "if", "not", "skipna", "and", "not", "mask"...
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. Exa...
[ "Parameters", "----------", "values", ":", "ndarray", "axis", ":", "int", "optional", "skipna", ":", "bool", "default", "True", "mask", ":", "ndarray", "[", "bool", "]", "optional", "nan", "-", "mask", "if", "known" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/nanops.py#L496-L558
train
pandas-dev/pandas
pandas/core/nanops.py
nanstd
def nanstd(values, axis=None, skipna=True, ddof=1, mask=None): """ 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 divis...
python
def nanstd(values, axis=None, skipna=True, ddof=1, mask=None): """ 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 divis...
[ "def", "nanstd", "(", "values", ",", "axis", "=", "None", ",", "skipna", "=", "True", ",", "ddof", "=", "1", ",", "mask", "=", "None", ")", ":", "result", "=", "np", ".", "sqrt", "(", "nanvar", "(", "values", ",", "axis", "=", "axis", ",", "ski...
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 ...
[ "Compute", "the", "standard", "deviation", "along", "given", "axis", "while", "ignoring", "NaNs" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/nanops.py#L581-L611
train