partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
Index.slice_indexer
For an ordered or unique index, compute the slice indexer for input labels and step. Parameters ---------- start : label, default None If None, defaults to the beginning end : label, default None If None, defaults to the end step : int, default No...
pandas/core/indexes/base.py
def slice_indexer(self, start=None, end=None, step=None, kind=None): """ For an ordered or unique index, compute the slice indexer for input labels and step. Parameters ---------- start : label, default None If None, defaults to the beginning end : la...
def slice_indexer(self, start=None, end=None, step=None, kind=None): """ For an ordered or unique index, compute the slice indexer for input labels and step. Parameters ---------- start : label, default None If None, defaults to the beginning end : la...
[ "For", "an", "ordered", "or", "unique", "index", "compute", "the", "slice", "indexer", "for", "input", "labels", "and", "step", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4625-L4673
[ "def", "slice_indexer", "(", "self", ",", "start", "=", "None", ",", "end", "=", "None", ",", "step", "=", "None", ",", "kind", "=", "None", ")", ":", "start_slice", ",", "end_slice", "=", "self", ".", "slice_locs", "(", "start", ",", "end", ",", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Index._maybe_cast_indexer
If we have a float key and are not a floating index, then try to cast to an int if equivalent.
pandas/core/indexes/base.py
def _maybe_cast_indexer(self, key): """ If we have a float key and are not a floating index, then try to cast to an int if equivalent. """ if is_float(key) and not self.is_floating(): try: ckey = int(key) if ckey == key: ...
def _maybe_cast_indexer(self, key): """ If we have a float key and are not a floating index, then try to cast to an int if equivalent. """ if is_float(key) and not self.is_floating(): try: ckey = int(key) if ckey == key: ...
[ "If", "we", "have", "a", "float", "key", "and", "are", "not", "a", "floating", "index", "then", "try", "to", "cast", "to", "an", "int", "if", "equivalent", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4675-L4688
[ "def", "_maybe_cast_indexer", "(", "self", ",", "key", ")", ":", "if", "is_float", "(", "key", ")", "and", "not", "self", ".", "is_floating", "(", ")", ":", "try", ":", "ckey", "=", "int", "(", "key", ")", "if", "ckey", "==", "key", ":", "key", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Index._validate_indexer
If we are positional indexer, validate that we have appropriate typed bounds must be an integer.
pandas/core/indexes/base.py
def _validate_indexer(self, form, key, kind): """ If we are positional indexer, validate that we have appropriate typed bounds must be an integer. """ assert kind in ['ix', 'loc', 'getitem', 'iloc'] if key is None: pass elif is_integer(key): ...
def _validate_indexer(self, form, key, kind): """ If we are positional indexer, validate that we have appropriate typed bounds must be an integer. """ assert kind in ['ix', 'loc', 'getitem', 'iloc'] if key is None: pass elif is_integer(key): ...
[ "If", "we", "are", "positional", "indexer", "validate", "that", "we", "have", "appropriate", "typed", "bounds", "must", "be", "an", "integer", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4690-L4703
[ "def", "_validate_indexer", "(", "self", ",", "form", ",", "key", ",", "kind", ")", ":", "assert", "kind", "in", "[", "'ix'", ",", "'loc'", ",", "'getitem'", ",", "'iloc'", "]", "if", "key", "is", "None", ":", "pass", "elif", "is_integer", "(", "key"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Index.get_slice_bound
Calculate slice bound that corresponds to given label. Returns leftmost (one-past-the-rightmost if ``side=='right'``) position of given label. Parameters ---------- label : object side : {'left', 'right'} kind : {'ix', 'loc', 'getitem'}
pandas/core/indexes/base.py
def get_slice_bound(self, label, side, kind): """ Calculate slice bound that corresponds to given label. Returns leftmost (one-past-the-rightmost if ``side=='right'``) position of given label. Parameters ---------- label : object side : {'left', 'right'}...
def get_slice_bound(self, label, side, kind): """ Calculate slice bound that corresponds to given label. Returns leftmost (one-past-the-rightmost if ``side=='right'``) position of given label. Parameters ---------- label : object side : {'left', 'right'}...
[ "Calculate", "slice", "bound", "that", "corresponds", "to", "given", "label", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4766-L4822
[ "def", "get_slice_bound", "(", "self", ",", "label", ",", "side", ",", "kind", ")", ":", "assert", "kind", "in", "[", "'ix'", ",", "'loc'", ",", "'getitem'", ",", "None", "]", "if", "side", "not", "in", "(", "'left'", ",", "'right'", ")", ":", "rai...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Index.slice_locs
Compute slice locations for input labels. Parameters ---------- start : label, default None If None, defaults to the beginning end : label, default None If None, defaults to the end step : int, defaults None If None, defaults to 1 kind...
pandas/core/indexes/base.py
def slice_locs(self, start=None, end=None, step=None, kind=None): """ Compute slice locations for input labels. Parameters ---------- start : label, default None If None, defaults to the beginning end : label, default None If None, defaults to the...
def slice_locs(self, start=None, end=None, step=None, kind=None): """ Compute slice locations for input labels. Parameters ---------- start : label, default None If None, defaults to the beginning end : label, default None If None, defaults to the...
[ "Compute", "slice", "locations", "for", "input", "labels", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4824-L4913
[ "def", "slice_locs", "(", "self", ",", "start", "=", "None", ",", "end", "=", "None", ",", "step", "=", "None", ",", "kind", "=", "None", ")", ":", "inc", "=", "(", "step", "is", "None", "or", "step", ">=", "0", ")", "if", "not", "inc", ":", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Index.delete
Make new Index with passed location(-s) deleted. Returns ------- new_index : Index
pandas/core/indexes/base.py
def delete(self, loc): """ Make new Index with passed location(-s) deleted. Returns ------- new_index : Index """ return self._shallow_copy(np.delete(self._data, loc))
def delete(self, loc): """ Make new Index with passed location(-s) deleted. Returns ------- new_index : Index """ return self._shallow_copy(np.delete(self._data, loc))
[ "Make", "new", "Index", "with", "passed", "location", "(", "-", "s", ")", "deleted", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4915-L4923
[ "def", "delete", "(", "self", ",", "loc", ")", ":", "return", "self", ".", "_shallow_copy", "(", "np", ".", "delete", "(", "self", ".", "_data", ",", "loc", ")", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Index.insert
Make new Index inserting new item at location. Follows Python list.append semantics for negative values. Parameters ---------- loc : int item : object Returns ------- new_index : Index
pandas/core/indexes/base.py
def insert(self, loc, item): """ Make new Index inserting new item at location. Follows Python list.append semantics for negative values. Parameters ---------- loc : int item : object Returns ------- new_index : Index """ ...
def insert(self, loc, item): """ Make new Index inserting new item at location. Follows Python list.append semantics for negative values. Parameters ---------- loc : int item : object Returns ------- new_index : Index """ ...
[ "Make", "new", "Index", "inserting", "new", "item", "at", "location", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4925-L4943
[ "def", "insert", "(", "self", ",", "loc", ",", "item", ")", ":", "_self", "=", "np", ".", "asarray", "(", "self", ")", "item", "=", "self", ".", "_coerce_scalar_to_index", "(", "item", ")", ".", "_ndarray_values", "idx", "=", "np", ".", "concatenate", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Index.drop
Make new Index with passed list of labels deleted. Parameters ---------- labels : array-like errors : {'ignore', 'raise'}, default 'raise' If 'ignore', suppress error and existing labels are dropped. Returns ------- dropped : Index Raises ...
pandas/core/indexes/base.py
def drop(self, labels, errors='raise'): """ Make new Index with passed list of labels deleted. Parameters ---------- labels : array-like errors : {'ignore', 'raise'}, default 'raise' If 'ignore', suppress error and existing labels are dropped. Return...
def drop(self, labels, errors='raise'): """ Make new Index with passed list of labels deleted. Parameters ---------- labels : array-like errors : {'ignore', 'raise'}, default 'raise' If 'ignore', suppress error and existing labels are dropped. Return...
[ "Make", "new", "Index", "with", "passed", "list", "of", "labels", "deleted", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4945-L4973
[ "def", "drop", "(", "self", ",", "labels", ",", "errors", "=", "'raise'", ")", ":", "arr_dtype", "=", "'object'", "if", "self", ".", "dtype", "==", "'object'", "else", "None", "labels", "=", "com", ".", "index_labels_to_array", "(", "labels", ",", "dtype...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Index._add_comparison_methods
Add in comparison methods.
pandas/core/indexes/base.py
def _add_comparison_methods(cls): """ Add in comparison methods. """ cls.__eq__ = _make_comparison_op(operator.eq, cls) cls.__ne__ = _make_comparison_op(operator.ne, cls) cls.__lt__ = _make_comparison_op(operator.lt, cls) cls.__gt__ = _make_comparison_op(operator....
def _add_comparison_methods(cls): """ Add in comparison methods. """ cls.__eq__ = _make_comparison_op(operator.eq, cls) cls.__ne__ = _make_comparison_op(operator.ne, cls) cls.__lt__ = _make_comparison_op(operator.lt, cls) cls.__gt__ = _make_comparison_op(operator....
[ "Add", "in", "comparison", "methods", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L5004-L5013
[ "def", "_add_comparison_methods", "(", "cls", ")", ":", "cls", ".", "__eq__", "=", "_make_comparison_op", "(", "operator", ".", "eq", ",", "cls", ")", "cls", ".", "__ne__", "=", "_make_comparison_op", "(", "operator", ".", "ne", ",", "cls", ")", "cls", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Index._add_numeric_methods_add_sub_disabled
Add in the numeric add/sub methods to disable.
pandas/core/indexes/base.py
def _add_numeric_methods_add_sub_disabled(cls): """ Add in the numeric add/sub methods to disable. """ cls.__add__ = make_invalid_op('__add__') cls.__radd__ = make_invalid_op('__radd__') cls.__iadd__ = make_invalid_op('__iadd__') cls.__sub__ = make_invalid_op('__s...
def _add_numeric_methods_add_sub_disabled(cls): """ Add in the numeric add/sub methods to disable. """ cls.__add__ = make_invalid_op('__add__') cls.__radd__ = make_invalid_op('__radd__') cls.__iadd__ = make_invalid_op('__iadd__') cls.__sub__ = make_invalid_op('__s...
[ "Add", "in", "the", "numeric", "add", "/", "sub", "methods", "to", "disable", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L5016-L5025
[ "def", "_add_numeric_methods_add_sub_disabled", "(", "cls", ")", ":", "cls", ".", "__add__", "=", "make_invalid_op", "(", "'__add__'", ")", "cls", ".", "__radd__", "=", "make_invalid_op", "(", "'__radd__'", ")", "cls", ".", "__iadd__", "=", "make_invalid_op", "(...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Index._add_numeric_methods_disabled
Add in numeric methods to disable other than add/sub.
pandas/core/indexes/base.py
def _add_numeric_methods_disabled(cls): """ Add in numeric methods to disable other than add/sub. """ cls.__pow__ = make_invalid_op('__pow__') cls.__rpow__ = make_invalid_op('__rpow__') cls.__mul__ = make_invalid_op('__mul__') cls.__rmul__ = make_invalid_op('__rmu...
def _add_numeric_methods_disabled(cls): """ Add in numeric methods to disable other than add/sub. """ cls.__pow__ = make_invalid_op('__pow__') cls.__rpow__ = make_invalid_op('__rpow__') cls.__mul__ = make_invalid_op('__mul__') cls.__rmul__ = make_invalid_op('__rmu...
[ "Add", "in", "numeric", "methods", "to", "disable", "other", "than", "add", "/", "sub", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L5028-L5045
[ "def", "_add_numeric_methods_disabled", "(", "cls", ")", ":", "cls", ".", "__pow__", "=", "make_invalid_op", "(", "'__pow__'", ")", "cls", ".", "__rpow__", "=", "make_invalid_op", "(", "'__rpow__'", ")", "cls", ".", "__mul__", "=", "make_invalid_op", "(", "'__...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Index._validate_for_numeric_unaryop
Validate if we can perform a numeric unary operation.
pandas/core/indexes/base.py
def _validate_for_numeric_unaryop(self, op, opstr): """ Validate if we can perform a numeric unary operation. """ if not self._is_numeric_dtype: raise TypeError("cannot evaluate a numeric op " "{opstr} for type: {typ}" ....
def _validate_for_numeric_unaryop(self, op, opstr): """ Validate if we can perform a numeric unary operation. """ if not self._is_numeric_dtype: raise TypeError("cannot evaluate a numeric op " "{opstr} for type: {typ}" ....
[ "Validate", "if", "we", "can", "perform", "a", "numeric", "unary", "operation", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L5053-L5060
[ "def", "_validate_for_numeric_unaryop", "(", "self", ",", "op", ",", "opstr", ")", ":", "if", "not", "self", ".", "_is_numeric_dtype", ":", "raise", "TypeError", "(", "\"cannot evaluate a numeric op \"", "\"{opstr} for type: {typ}\"", ".", "format", "(", "opstr", "=...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Index._validate_for_numeric_binop
Return valid other; evaluate or raise TypeError if we are not of the appropriate type. Notes ----- This is an internal method called by ops.
pandas/core/indexes/base.py
def _validate_for_numeric_binop(self, other, op): """ Return valid other; evaluate or raise TypeError if we are not of the appropriate type. Notes ----- This is an internal method called by ops. """ opstr = '__{opname}__'.format(opname=op.__name__) ...
def _validate_for_numeric_binop(self, other, op): """ Return valid other; evaluate or raise TypeError if we are not of the appropriate type. Notes ----- This is an internal method called by ops. """ opstr = '__{opname}__'.format(opname=op.__name__) ...
[ "Return", "valid", "other", ";", "evaluate", "or", "raise", "TypeError", "if", "we", "are", "not", "of", "the", "appropriate", "type", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L5062-L5105
[ "def", "_validate_for_numeric_binop", "(", "self", ",", "other", ",", "op", ")", ":", "opstr", "=", "'__{opname}__'", ".", "format", "(", "opname", "=", "op", ".", "__name__", ")", "# if we are an inheritor of numeric,", "# but not actually numeric (e.g. DatetimeIndex/P...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Index._add_numeric_methods_binary
Add in numeric methods.
pandas/core/indexes/base.py
def _add_numeric_methods_binary(cls): """ Add in numeric methods. """ cls.__add__ = _make_arithmetic_op(operator.add, cls) cls.__radd__ = _make_arithmetic_op(ops.radd, cls) cls.__sub__ = _make_arithmetic_op(operator.sub, cls) cls.__rsub__ = _make_arithmetic_op(ops...
def _add_numeric_methods_binary(cls): """ Add in numeric methods. """ cls.__add__ = _make_arithmetic_op(operator.add, cls) cls.__radd__ = _make_arithmetic_op(ops.radd, cls) cls.__sub__ = _make_arithmetic_op(operator.sub, cls) cls.__rsub__ = _make_arithmetic_op(ops...
[ "Add", "in", "numeric", "methods", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L5108-L5128
[ "def", "_add_numeric_methods_binary", "(", "cls", ")", ":", "cls", ".", "__add__", "=", "_make_arithmetic_op", "(", "operator", ".", "add", ",", "cls", ")", "cls", ".", "__radd__", "=", "_make_arithmetic_op", "(", "ops", ".", "radd", ",", "cls", ")", "cls"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Index._add_numeric_methods_unary
Add in numeric unary methods.
pandas/core/indexes/base.py
def _add_numeric_methods_unary(cls): """ Add in numeric unary methods. """ def _make_evaluate_unary(op, opstr): def _evaluate_numeric_unary(self): self._validate_for_numeric_unaryop(op, opstr) attrs = self._get_attributes_dict() ...
def _add_numeric_methods_unary(cls): """ Add in numeric unary methods. """ def _make_evaluate_unary(op, opstr): def _evaluate_numeric_unary(self): self._validate_for_numeric_unaryop(op, opstr) attrs = self._get_attributes_dict() ...
[ "Add", "in", "numeric", "unary", "methods", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L5131-L5150
[ "def", "_add_numeric_methods_unary", "(", "cls", ")", ":", "def", "_make_evaluate_unary", "(", "op", ",", "opstr", ")", ":", "def", "_evaluate_numeric_unary", "(", "self", ")", ":", "self", ".", "_validate_for_numeric_unaryop", "(", "op", ",", "opstr", ")", "a...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Index._add_logical_methods
Add in logical methods.
pandas/core/indexes/base.py
def _add_logical_methods(cls): """ Add in logical methods. """ _doc = """ %(desc)s Parameters ---------- *args These parameters will be passed to numpy.%(outname)s. **kwargs These parameters will be passed to numpy.%(outnam...
def _add_logical_methods(cls): """ Add in logical methods. """ _doc = """ %(desc)s Parameters ---------- *args These parameters will be passed to numpy.%(outname)s. **kwargs These parameters will be passed to numpy.%(outnam...
[ "Add", "in", "logical", "methods", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L5158-L5261
[ "def", "_add_logical_methods", "(", "cls", ")", ":", "_doc", "=", "\"\"\"\n %(desc)s\n\n Parameters\n ----------\n *args\n These parameters will be passed to numpy.%(outname)s.\n **kwargs\n These parameters will be passed to numpy.%(outname)s....
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_get_grouper
create and return a BaseGrouper, which is an internal mapping of how to create the grouper indexers. This may be composed of multiple Grouping objects, indicating multiple groupers Groupers are ultimately index mappings. They can originate as: index mappings, keys to columns, functions, or Groupers...
pandas/core/groupby/grouper.py
def _get_grouper(obj, key=None, axis=0, level=None, sort=True, observed=False, mutated=False, validate=True): """ create and return a BaseGrouper, which is an internal mapping of how to create the grouper indexers. This may be composed of multiple Grouping objects, indicating multip...
def _get_grouper(obj, key=None, axis=0, level=None, sort=True, observed=False, mutated=False, validate=True): """ create and return a BaseGrouper, which is an internal mapping of how to create the grouper indexers. This may be composed of multiple Grouping objects, indicating multip...
[ "create", "and", "return", "a", "BaseGrouper", "which", "is", "an", "internal", "mapping", "of", "how", "to", "create", "the", "grouper", "indexers", ".", "This", "may", "be", "composed", "of", "multiple", "Grouping", "objects", "indicating", "multiple", "grou...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/grouper.py#L406-L612
[ "def", "_get_grouper", "(", "obj", ",", "key", "=", "None", ",", "axis", "=", "0", ",", "level", "=", "None", ",", "sort", "=", "True", ",", "observed", "=", "False", ",", "mutated", "=", "False", ",", "validate", "=", "True", ")", ":", "group_axis...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Grouper._get_grouper
Parameters ---------- obj : the subject object validate : boolean, default True if True, validate the grouper Returns ------- a tuple of binner, grouper, obj (possibly sorted)
pandas/core/groupby/grouper.py
def _get_grouper(self, obj, validate=True): """ Parameters ---------- obj : the subject object validate : boolean, default True if True, validate the grouper Returns ------- a tuple of binner, grouper, obj (possibly sorted) """ ...
def _get_grouper(self, obj, validate=True): """ Parameters ---------- obj : the subject object validate : boolean, default True if True, validate the grouper Returns ------- a tuple of binner, grouper, obj (possibly sorted) """ ...
[ "Parameters", "----------", "obj", ":", "the", "subject", "object", "validate", ":", "boolean", "default", "True", "if", "True", "validate", "the", "grouper" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/grouper.py#L112-L131
[ "def", "_get_grouper", "(", "self", ",", "obj", ",", "validate", "=", "True", ")", ":", "self", ".", "_set_grouper", "(", "obj", ")", "self", ".", "grouper", ",", "exclusions", ",", "self", ".", "obj", "=", "_get_grouper", "(", "self", ".", "obj", ",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Grouper._set_grouper
given an object and the specifications, setup the internal grouper for this particular specification Parameters ---------- obj : the subject object sort : bool, default False whether the resulting grouper should be sorted
pandas/core/groupby/grouper.py
def _set_grouper(self, obj, sort=False): """ given an object and the specifications, setup the internal grouper for this particular specification Parameters ---------- obj : the subject object sort : bool, default False whether the resulting grouper s...
def _set_grouper(self, obj, sort=False): """ given an object and the specifications, setup the internal grouper for this particular specification Parameters ---------- obj : the subject object sort : bool, default False whether the resulting grouper s...
[ "given", "an", "object", "and", "the", "specifications", "setup", "the", "internal", "grouper", "for", "this", "particular", "specification" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/grouper.py#L133-L192
[ "def", "_set_grouper", "(", "self", ",", "obj", ",", "sort", "=", "False", ")", ":", "if", "self", ".", "key", "is", "not", "None", "and", "self", ".", "level", "is", "not", "None", ":", "raise", "ValueError", "(", "\"The Grouper cannot specify both a key ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
to_pickle
Pickle (serialize) object to file. Parameters ---------- obj : any object Any python object. path : str File path where the pickled object will be stored. compression : {'infer', 'gzip', 'bz2', 'zip', 'xz', None}, default 'infer' A string representing the compression to use ...
pandas/io/pickle.py
def to_pickle(obj, path, compression='infer', protocol=pickle.HIGHEST_PROTOCOL): """ Pickle (serialize) object to file. Parameters ---------- obj : any object Any python object. path : str File path where the pickled object will be stored. compression : {'infer...
def to_pickle(obj, path, compression='infer', protocol=pickle.HIGHEST_PROTOCOL): """ Pickle (serialize) object to file. Parameters ---------- obj : any object Any python object. path : str File path where the pickled object will be stored. compression : {'infer...
[ "Pickle", "(", "serialize", ")", "object", "to", "file", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/pickle.py#L13-L83
[ "def", "to_pickle", "(", "obj", ",", "path", ",", "compression", "=", "'infer'", ",", "protocol", "=", "pickle", ".", "HIGHEST_PROTOCOL", ")", ":", "path", "=", "_stringify_path", "(", "path", ")", "f", ",", "fh", "=", "_get_handle", "(", "path", ",", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
read_pickle
Load pickled pandas object (or any object) from file. .. warning:: Loading pickled data received from untrusted sources can be unsafe. See `here <https://docs.python.org/3/library/pickle.html>`__. Parameters ---------- path : str File path where the pickled object will be loaded...
pandas/io/pickle.py
def read_pickle(path, compression='infer'): """ Load pickled pandas object (or any object) from file. .. warning:: Loading pickled data received from untrusted sources can be unsafe. See `here <https://docs.python.org/3/library/pickle.html>`__. Parameters ---------- path : str ...
def read_pickle(path, compression='infer'): """ Load pickled pandas object (or any object) from file. .. warning:: Loading pickled data received from untrusted sources can be unsafe. See `here <https://docs.python.org/3/library/pickle.html>`__. Parameters ---------- path : str ...
[ "Load", "pickled", "pandas", "object", "(", "or", "any", "object", ")", "from", "file", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/pickle.py#L86-L163
[ "def", "read_pickle", "(", "path", ",", "compression", "=", "'infer'", ")", ":", "path", "=", "_stringify_path", "(", "path", ")", "f", ",", "fh", "=", "_get_handle", "(", "path", ",", "'rb'", ",", "compression", "=", "compression", ",", "is_text", "=", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
mask_missing
Return a masking array of same size/shape as arr with entries equaling any member of values_to_mask set to True
pandas/core/missing.py
def mask_missing(arr, values_to_mask): """ Return a masking array of same size/shape as arr with entries equaling any member of values_to_mask set to True """ dtype, values_to_mask = infer_dtype_from_array(values_to_mask) try: values_to_mask = np.array(values_to_mask, dtype=dtype) ...
def mask_missing(arr, values_to_mask): """ Return a masking array of same size/shape as arr with entries equaling any member of values_to_mask set to True """ dtype, values_to_mask = infer_dtype_from_array(values_to_mask) try: values_to_mask = np.array(values_to_mask, dtype=dtype) ...
[ "Return", "a", "masking", "array", "of", "same", "size", "/", "shape", "as", "arr", "with", "entries", "equaling", "any", "member", "of", "values_to_mask", "set", "to", "True" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L18-L66
[ "def", "mask_missing", "(", "arr", ",", "values_to_mask", ")", ":", "dtype", ",", "values_to_mask", "=", "infer_dtype_from_array", "(", "values_to_mask", ")", "try", ":", "values_to_mask", "=", "np", ".", "array", "(", "values_to_mask", ",", "dtype", "=", "dty...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
interpolate_1d
Logic for the 1-d interpolation. The result should be 1-d, inputs xvalues and yvalues will each be 1-d arrays of the same length. Bounds_error is currently hardcoded to False since non-scipy ones don't take it as an argument.
pandas/core/missing.py
def interpolate_1d(xvalues, yvalues, method='linear', limit=None, limit_direction='forward', limit_area=None, fill_value=None, bounds_error=False, order=None, **kwargs): """ Logic for the 1-d interpolation. The result should be 1-d, inputs xvalues and yvalues will each...
def interpolate_1d(xvalues, yvalues, method='linear', limit=None, limit_direction='forward', limit_area=None, fill_value=None, bounds_error=False, order=None, **kwargs): """ Logic for the 1-d interpolation. The result should be 1-d, inputs xvalues and yvalues will each...
[ "Logic", "for", "the", "1", "-", "d", "interpolation", ".", "The", "result", "should", "be", "1", "-", "d", "inputs", "xvalues", "and", "yvalues", "will", "each", "be", "1", "-", "d", "arrays", "of", "the", "same", "length", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L109-L239
[ "def", "interpolate_1d", "(", "xvalues", ",", "yvalues", ",", "method", "=", "'linear'", ",", "limit", "=", "None", ",", "limit_direction", "=", "'forward'", ",", "limit_area", "=", "None", ",", "fill_value", "=", "None", ",", "bounds_error", "=", "False", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_interpolate_scipy_wrapper
Passed off to scipy.interpolate.interp1d. method is scipy's kind. Returns an array interpolated at new_x. Add any new methods to the list in _clean_interp_method.
pandas/core/missing.py
def _interpolate_scipy_wrapper(x, y, new_x, method, fill_value=None, bounds_error=False, order=None, **kwargs): """ Passed off to scipy.interpolate.interp1d. method is scipy's kind. Returns an array interpolated at new_x. Add any new methods to the list in _clean_interp_m...
def _interpolate_scipy_wrapper(x, y, new_x, method, fill_value=None, bounds_error=False, order=None, **kwargs): """ Passed off to scipy.interpolate.interp1d. method is scipy's kind. Returns an array interpolated at new_x. Add any new methods to the list in _clean_interp_m...
[ "Passed", "off", "to", "scipy", ".", "interpolate", ".", "interp1d", ".", "method", "is", "scipy", "s", "kind", ".", "Returns", "an", "array", "interpolated", "at", "new_x", ".", "Add", "any", "new", "methods", "to", "the", "list", "in", "_clean_interp_met...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L242-L311
[ "def", "_interpolate_scipy_wrapper", "(", "x", ",", "y", ",", "new_x", ",", "method", ",", "fill_value", "=", "None", ",", "bounds_error", "=", "False", ",", "order", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "from", "scipy", "import"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_from_derivatives
Convenience function for interpolate.BPoly.from_derivatives. Construct a piecewise polynomial in the Bernstein basis, compatible with the specified values and derivatives at breakpoints. Parameters ---------- xi : array_like sorted 1D array of x-coordinates yi : array_like or list of a...
pandas/core/missing.py
def _from_derivatives(xi, yi, x, order=None, der=0, extrapolate=False): """ Convenience function for interpolate.BPoly.from_derivatives. Construct a piecewise polynomial in the Bernstein basis, compatible with the specified values and derivatives at breakpoints. Parameters ---------- xi : ...
def _from_derivatives(xi, yi, x, order=None, der=0, extrapolate=False): """ Convenience function for interpolate.BPoly.from_derivatives. Construct a piecewise polynomial in the Bernstein basis, compatible with the specified values and derivatives at breakpoints. Parameters ---------- xi : ...
[ "Convenience", "function", "for", "interpolate", ".", "BPoly", ".", "from_derivatives", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L314-L355
[ "def", "_from_derivatives", "(", "xi", ",", "yi", ",", "x", ",", "order", "=", "None", ",", "der", "=", "0", ",", "extrapolate", "=", "False", ")", ":", "from", "scipy", "import", "interpolate", "# return the method for compat with scipy version & backwards compat...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_akima_interpolate
Convenience function for akima interpolation. xi and yi are arrays of values used to approximate some function f, with ``yi = f(xi)``. See `Akima1DInterpolator` for details. Parameters ---------- xi : array_like A sorted list of x-coordinates, of length N. yi : array_like ...
pandas/core/missing.py
def _akima_interpolate(xi, yi, x, der=0, axis=0): """ Convenience function for akima interpolation. xi and yi are arrays of values used to approximate some function f, with ``yi = f(xi)``. See `Akima1DInterpolator` for details. Parameters ---------- xi : array_like A sorted lis...
def _akima_interpolate(xi, yi, x, der=0, axis=0): """ Convenience function for akima interpolation. xi and yi are arrays of values used to approximate some function f, with ``yi = f(xi)``. See `Akima1DInterpolator` for details. Parameters ---------- xi : array_like A sorted lis...
[ "Convenience", "function", "for", "akima", "interpolation", ".", "xi", "and", "yi", "are", "arrays", "of", "values", "used", "to", "approximate", "some", "function", "f", "with", "yi", "=", "f", "(", "xi", ")", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L358-L405
[ "def", "_akima_interpolate", "(", "xi", ",", "yi", ",", "x", ",", "der", "=", "0", ",", "axis", "=", "0", ")", ":", "from", "scipy", "import", "interpolate", "try", ":", "P", "=", "interpolate", ".", "Akima1DInterpolator", "(", "xi", ",", "yi", ",", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
interpolate_2d
Perform an actual interpolation of values, values will be make 2-d if needed fills inplace, returns the result.
pandas/core/missing.py
def interpolate_2d(values, method='pad', axis=0, limit=None, fill_value=None, dtype=None): """ Perform an actual interpolation of values, values will be make 2-d if needed fills inplace, returns the result. """ transf = (lambda x: x) if axis == 0 else (lambda x: x.T) # resha...
def interpolate_2d(values, method='pad', axis=0, limit=None, fill_value=None, dtype=None): """ Perform an actual interpolation of values, values will be make 2-d if needed fills inplace, returns the result. """ transf = (lambda x: x) if axis == 0 else (lambda x: x.T) # resha...
[ "Perform", "an", "actual", "interpolation", "of", "values", "values", "will", "be", "make", "2", "-", "d", "if", "needed", "fills", "inplace", "returns", "the", "result", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L408-L442
[ "def", "interpolate_2d", "(", "values", ",", "method", "=", "'pad'", ",", "axis", "=", "0", ",", "limit", "=", "None", ",", "fill_value", "=", "None", ",", "dtype", "=", "None", ")", ":", "transf", "=", "(", "lambda", "x", ":", "x", ")", "if", "a...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_cast_values_for_fillna
Cast values to a dtype that algos.pad and algos.backfill can handle.
pandas/core/missing.py
def _cast_values_for_fillna(values, dtype): """ Cast values to a dtype that algos.pad and algos.backfill can handle. """ # TODO: for int-dtypes we make a copy, but for everything else this # alters the values in-place. Is this intentional? if (is_datetime64_dtype(dtype) or is_datetime64tz_dty...
def _cast_values_for_fillna(values, dtype): """ Cast values to a dtype that algos.pad and algos.backfill can handle. """ # TODO: for int-dtypes we make a copy, but for everything else this # alters the values in-place. Is this intentional? if (is_datetime64_dtype(dtype) or is_datetime64tz_dty...
[ "Cast", "values", "to", "a", "dtype", "that", "algos", ".", "pad", "and", "algos", ".", "backfill", "can", "handle", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L445-L460
[ "def", "_cast_values_for_fillna", "(", "values", ",", "dtype", ")", ":", "# TODO: for int-dtypes we make a copy, but for everything else this", "# alters the values in-place. Is this intentional?", "if", "(", "is_datetime64_dtype", "(", "dtype", ")", "or", "is_datetime64tz_dtype"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
fill_zeros
If this is a reversed op, then flip x,y If we have an integer value (or array in y) and we have 0's, fill them with the fill, return the result. Mask the nan's from x.
pandas/core/missing.py
def fill_zeros(result, x, y, name, fill): """ If this is a reversed op, then flip x,y If we have an integer value (or array in y) and we have 0's, fill them with the fill, return the result. Mask the nan's from x. """ if fill is None or is_float_dtype(result): return result ...
def fill_zeros(result, x, y, name, fill): """ If this is a reversed op, then flip x,y If we have an integer value (or array in y) and we have 0's, fill them with the fill, return the result. Mask the nan's from x. """ if fill is None or is_float_dtype(result): return result ...
[ "If", "this", "is", "a", "reversed", "op", "then", "flip", "x", "y" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L524-L576
[ "def", "fill_zeros", "(", "result", ",", "x", ",", "y", ",", "name", ",", "fill", ")", ":", "if", "fill", "is", "None", "or", "is_float_dtype", "(", "result", ")", ":", "return", "result", "if", "name", ".", "startswith", "(", "(", "'r'", ",", "'__...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
mask_zero_div_zero
Set results of 0 / 0 or 0 // 0 to np.nan, regardless of the dtypes of the numerator or the denominator. Parameters ---------- x : ndarray y : ndarray result : ndarray copy : bool (default False) Whether to always create a new array or try to fill in the existing array if pos...
pandas/core/missing.py
def mask_zero_div_zero(x, y, result, copy=False): """ Set results of 0 / 0 or 0 // 0 to np.nan, regardless of the dtypes of the numerator or the denominator. Parameters ---------- x : ndarray y : ndarray result : ndarray copy : bool (default False) Whether to always create a...
def mask_zero_div_zero(x, y, result, copy=False): """ Set results of 0 / 0 or 0 // 0 to np.nan, regardless of the dtypes of the numerator or the denominator. Parameters ---------- x : ndarray y : ndarray result : ndarray copy : bool (default False) Whether to always create a...
[ "Set", "results", "of", "0", "/", "0", "or", "0", "//", "0", "to", "np", ".", "nan", "regardless", "of", "the", "dtypes", "of", "the", "numerator", "or", "the", "denominator", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L579-L628
[ "def", "mask_zero_div_zero", "(", "x", ",", "y", ",", "result", ",", "copy", "=", "False", ")", ":", "if", "is_scalar", "(", "y", ")", ":", "y", "=", "np", ".", "array", "(", "y", ")", "zmask", "=", "y", "==", "0", "if", "zmask", ".", "any", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
dispatch_missing
Fill nulls caused by division by zero, casting to a diffferent dtype if necessary. Parameters ---------- op : function (operator.add, operator.div, ...) left : object (Index for non-reversed ops) right : object (Index fof reversed ops) result : ndarray Returns ------- result : ...
pandas/core/missing.py
def dispatch_missing(op, left, right, result): """ Fill nulls caused by division by zero, casting to a diffferent dtype if necessary. Parameters ---------- op : function (operator.add, operator.div, ...) left : object (Index for non-reversed ops) right : object (Index fof reversed ops) ...
def dispatch_missing(op, left, right, result): """ Fill nulls caused by division by zero, casting to a diffferent dtype if necessary. Parameters ---------- op : function (operator.add, operator.div, ...) left : object (Index for non-reversed ops) right : object (Index fof reversed ops) ...
[ "Fill", "nulls", "caused", "by", "division", "by", "zero", "casting", "to", "a", "diffferent", "dtype", "if", "necessary", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L631-L657
[ "def", "dispatch_missing", "(", "op", ",", "left", ",", "right", ",", "result", ")", ":", "opstr", "=", "'__{opname}__'", ".", "format", "(", "opname", "=", "op", ".", "__name__", ")", ".", "replace", "(", "'____'", ",", "'__'", ")", "if", "op", "in"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_interp_limit
Get indexers of values that won't be filled because they exceed the limits. Parameters ---------- invalid : boolean ndarray fw_limit : int or None forward limit to index bw_limit : int or None backward limit to index Returns ------- set of indexers Notes --...
pandas/core/missing.py
def _interp_limit(invalid, fw_limit, bw_limit): """ Get indexers of values that won't be filled because they exceed the limits. Parameters ---------- invalid : boolean ndarray fw_limit : int or None forward limit to index bw_limit : int or None backward limit to index ...
def _interp_limit(invalid, fw_limit, bw_limit): """ Get indexers of values that won't be filled because they exceed the limits. Parameters ---------- invalid : boolean ndarray fw_limit : int or None forward limit to index bw_limit : int or None backward limit to index ...
[ "Get", "indexers", "of", "values", "that", "won", "t", "be", "filled", "because", "they", "exceed", "the", "limits", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L660-L721
[ "def", "_interp_limit", "(", "invalid", ",", "fw_limit", ",", "bw_limit", ")", ":", "# handle forward first; the backward direction is the same except", "# 1. operate on the reversed array", "# 2. subtract the returned indices from N - 1", "N", "=", "len", "(", "invalid", ")", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_rolling_window
[True, True, False, True, False], 2 -> [ [True, True], [True, False], [False, True], [True, False], ]
pandas/core/missing.py
def _rolling_window(a, window): """ [True, True, False, True, False], 2 -> [ [True, True], [True, False], [False, True], [True, False], ] """ # https://stackoverflow.com/a/6811241 shape = a.shape[:-1] + (a.shape[-1] - window + 1, window) strides = a.stri...
def _rolling_window(a, window): """ [True, True, False, True, False], 2 -> [ [True, True], [True, False], [False, True], [True, False], ] """ # https://stackoverflow.com/a/6811241 shape = a.shape[:-1] + (a.shape[-1] - window + 1, window) strides = a.stri...
[ "[", "True", "True", "False", "True", "False", "]", "2", "-", ">" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L724-L738
[ "def", "_rolling_window", "(", "a", ",", "window", ")", ":", "# https://stackoverflow.com/a/6811241", "shape", "=", "a", ".", "shape", "[", ":", "-", "1", "]", "+", "(", "a", ".", "shape", "[", "-", "1", "]", "-", "window", "+", "1", ",", "window", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
get_console_size
Return console size as tuple = (width, height). Returns (None,None) in non-interactive session.
pandas/io/formats/console.py
def get_console_size(): """Return console size as tuple = (width, height). Returns (None,None) in non-interactive session. """ from pandas import get_option display_width = get_option('display.width') # deprecated. display_height = get_option('display.max_rows') # Consider # inter...
def get_console_size(): """Return console size as tuple = (width, height). Returns (None,None) in non-interactive session. """ from pandas import get_option display_width = get_option('display.width') # deprecated. display_height = get_option('display.max_rows') # Consider # inter...
[ "Return", "console", "size", "as", "tuple", "=", "(", "width", "height", ")", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/console.py#L8-L45
[ "def", "get_console_size", "(", ")", ":", "from", "pandas", "import", "get_option", "display_width", "=", "get_option", "(", "'display.width'", ")", "# deprecated.", "display_height", "=", "get_option", "(", "'display.max_rows'", ")", "# Consider", "# interactive shell ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
in_interactive_session
check if we're running in an interactive shell returns True if running under python/ipython interactive shell
pandas/io/formats/console.py
def in_interactive_session(): """ check if we're running in an interactive shell returns True if running under python/ipython interactive shell """ from pandas import get_option def check_main(): try: import __main__ as main except ModuleNotFoundError: retur...
def in_interactive_session(): """ check if we're running in an interactive shell returns True if running under python/ipython interactive shell """ from pandas import get_option def check_main(): try: import __main__ as main except ModuleNotFoundError: retur...
[ "check", "if", "we", "re", "running", "in", "an", "interactive", "shell" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/console.py#L51-L69
[ "def", "in_interactive_session", "(", ")", ":", "from", "pandas", "import", "get_option", "def", "check_main", "(", ")", ":", "try", ":", "import", "__main__", "as", "main", "except", "ModuleNotFoundError", ":", "return", "get_option", "(", "'mode.sim_interactive'...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
recode_for_groupby
Code the categories to ensure we can groupby for categoricals. If observed=True, we return a new Categorical with the observed categories only. If sort=False, return a copy of self, coded with categories as returned by .unique(), followed by any categories not appearing in the data. If sort=True, ...
pandas/core/groupby/categorical.py
def recode_for_groupby(c, sort, observed): """ Code the categories to ensure we can groupby for categoricals. If observed=True, we return a new Categorical with the observed categories only. If sort=False, return a copy of self, coded with categories as returned by .unique(), followed by any c...
def recode_for_groupby(c, sort, observed): """ Code the categories to ensure we can groupby for categoricals. If observed=True, we return a new Categorical with the observed categories only. If sort=False, return a copy of self, coded with categories as returned by .unique(), followed by any c...
[ "Code", "the", "categories", "to", "ensure", "we", "can", "groupby", "for", "categoricals", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/categorical.py#L8-L74
[ "def", "recode_for_groupby", "(", "c", ",", "sort", ",", "observed", ")", ":", "# we only care about observed values", "if", "observed", ":", "unique_codes", "=", "unique1d", "(", "c", ".", "codes", ")", "take_codes", "=", "unique_codes", "[", "unique_codes", "!...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
recode_from_groupby
Reverse the codes_to_groupby to account for sort / observed. Parameters ---------- c : Categorical sort : boolean The value of the sort parameter groupby was called with. ci : CategoricalIndex The codes / categories to recode Returns ------- CategoricalIndex
pandas/core/groupby/categorical.py
def recode_from_groupby(c, sort, ci): """ Reverse the codes_to_groupby to account for sort / observed. Parameters ---------- c : Categorical sort : boolean The value of the sort parameter groupby was called with. ci : CategoricalIndex The codes / categories to recode Re...
def recode_from_groupby(c, sort, ci): """ Reverse the codes_to_groupby to account for sort / observed. Parameters ---------- c : Categorical sort : boolean The value of the sort parameter groupby was called with. ci : CategoricalIndex The codes / categories to recode Re...
[ "Reverse", "the", "codes_to_groupby", "to", "account", "for", "sort", "/", "observed", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/categorical.py#L77-L100
[ "def", "recode_from_groupby", "(", "c", ",", "sort", ",", "ci", ")", ":", "# we re-order to the original category orderings", "if", "sort", ":", "return", "ci", ".", "set_categories", "(", "c", ".", "categories", ")", "# we are not sorting, so add unobserved to the end"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
get_engine
return our implementation
pandas/io/parquet.py
def get_engine(engine): """ return our implementation """ if engine == 'auto': engine = get_option('io.parquet.engine') if engine == 'auto': # try engines in this order try: return PyArrowImpl() except ImportError: pass try: retu...
def get_engine(engine): """ return our implementation """ if engine == 'auto': engine = get_option('io.parquet.engine') if engine == 'auto': # try engines in this order try: return PyArrowImpl() except ImportError: pass try: retu...
[ "return", "our", "implementation" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parquet.py#L13-L42
[ "def", "get_engine", "(", "engine", ")", ":", "if", "engine", "==", "'auto'", ":", "engine", "=", "get_option", "(", "'io.parquet.engine'", ")", "if", "engine", "==", "'auto'", ":", "# try engines in this order", "try", ":", "return", "PyArrowImpl", "(", ")", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
to_parquet
Write a DataFrame to the parquet format. Parameters ---------- path : str File path or Root Directory path. Will be used as Root Directory path while writing a partitioned dataset. .. versionchanged:: 0.24.0 engine : {'auto', 'pyarrow', 'fastparquet'}, default 'auto' P...
pandas/io/parquet.py
def to_parquet(df, path, engine='auto', compression='snappy', index=None, partition_cols=None, **kwargs): """ Write a DataFrame to the parquet format. Parameters ---------- path : str File path or Root Directory path. Will be used as Root Directory path while writing ...
def to_parquet(df, path, engine='auto', compression='snappy', index=None, partition_cols=None, **kwargs): """ Write a DataFrame to the parquet format. Parameters ---------- path : str File path or Root Directory path. Will be used as Root Directory path while writing ...
[ "Write", "a", "DataFrame", "to", "the", "parquet", "format", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parquet.py#L213-L251
[ "def", "to_parquet", "(", "df", ",", "path", ",", "engine", "=", "'auto'", ",", "compression", "=", "'snappy'", ",", "index", "=", "None", ",", "partition_cols", "=", "None", ",", "*", "*", "kwargs", ")", ":", "impl", "=", "get_engine", "(", "engine", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
read_parquet
Load a parquet object from the file path, returning a DataFrame. .. versionadded 0.21.0 Parameters ---------- path : string File path engine : {'auto', 'pyarrow', 'fastparquet'}, default 'auto' Parquet library to use. If 'auto', then the option ``io.parquet.engine`` is used...
pandas/io/parquet.py
def read_parquet(path, engine='auto', columns=None, **kwargs): """ Load a parquet object from the file path, returning a DataFrame. .. versionadded 0.21.0 Parameters ---------- path : string File path engine : {'auto', 'pyarrow', 'fastparquet'}, default 'auto' Parquet libra...
def read_parquet(path, engine='auto', columns=None, **kwargs): """ Load a parquet object from the file path, returning a DataFrame. .. versionadded 0.21.0 Parameters ---------- path : string File path engine : {'auto', 'pyarrow', 'fastparquet'}, default 'auto' Parquet libra...
[ "Load", "a", "parquet", "object", "from", "the", "file", "path", "returning", "a", "DataFrame", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parquet.py#L254-L282
[ "def", "read_parquet", "(", "path", ",", "engine", "=", "'auto'", ",", "columns", "=", "None", ",", "*", "*", "kwargs", ")", ":", "impl", "=", "get_engine", "(", "engine", ")", "return", "impl", ".", "read", "(", "path", ",", "columns", "=", "columns...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
generate_bins_generic
Generate bin edge offsets and bin labels for one array using another array which has bin edge values. Both arrays must be sorted. Parameters ---------- values : array of values binner : a comparable array of values representing bins into which to bin the first array. Note, 'values' end-poin...
pandas/core/groupby/ops.py
def generate_bins_generic(values, binner, closed): """ Generate bin edge offsets and bin labels for one array using another array which has bin edge values. Both arrays must be sorted. Parameters ---------- values : array of values binner : a comparable array of values representing bins int...
def generate_bins_generic(values, binner, closed): """ Generate bin edge offsets and bin labels for one array using another array which has bin edge values. Both arrays must be sorted. Parameters ---------- values : array of values binner : a comparable array of values representing bins int...
[ "Generate", "bin", "edge", "offsets", "and", "bin", "labels", "for", "one", "array", "using", "another", "array", "which", "has", "bin", "edge", "values", ".", "Both", "arrays", "must", "be", "sorted", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/ops.py#L40-L89
[ "def", "generate_bins_generic", "(", "values", ",", "binner", ",", "closed", ")", ":", "lenidx", "=", "len", "(", "values", ")", "lenbin", "=", "len", "(", "binner", ")", "if", "lenidx", "<=", "0", "or", "lenbin", "<=", "0", ":", "raise", "ValueError",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BaseGrouper.get_iterator
Groupby iterator Returns ------- Generator yielding sequence of (name, subsetted object) for each group
pandas/core/groupby/ops.py
def get_iterator(self, data, axis=0): """ Groupby iterator Returns ------- Generator yielding sequence of (name, subsetted object) for each group """ splitter = self._get_splitter(data, axis=axis) keys = self._get_group_keys() for key, (i,...
def get_iterator(self, data, axis=0): """ Groupby iterator Returns ------- Generator yielding sequence of (name, subsetted object) for each group """ splitter = self._get_splitter(data, axis=axis) keys = self._get_group_keys() for key, (i,...
[ "Groupby", "iterator" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/ops.py#L136-L148
[ "def", "get_iterator", "(", "self", ",", "data", ",", "axis", "=", "0", ")", ":", "splitter", "=", "self", ".", "_get_splitter", "(", "data", ",", "axis", "=", "axis", ")", "keys", "=", "self", ".", "_get_group_keys", "(", ")", "for", "key", ",", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BaseGrouper.indices
dict {group name -> group indices}
pandas/core/groupby/ops.py
def indices(self): """ dict {group name -> group indices} """ if len(self.groupings) == 1: return self.groupings[0].indices else: label_list = [ping.labels for ping in self.groupings] keys = [com.values_from_object(ping.group_index) for pin...
def indices(self): """ dict {group name -> group indices} """ if len(self.groupings) == 1: return self.groupings[0].indices else: label_list = [ping.labels for ping in self.groupings] keys = [com.values_from_object(ping.group_index) for pin...
[ "dict", "{", "group", "name", "-", ">", "group", "indices", "}" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/ops.py#L219-L227
[ "def", "indices", "(", "self", ")", ":", "if", "len", "(", "self", ".", "groupings", ")", "==", "1", ":", "return", "self", ".", "groupings", "[", "0", "]", ".", "indices", "else", ":", "label_list", "=", "[", "ping", ".", "labels", "for", "ping", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BaseGrouper.size
Compute group sizes
pandas/core/groupby/ops.py
def size(self): """ Compute group sizes """ ids, _, ngroup = self.group_info ids = ensure_platform_int(ids) if ngroup: out = np.bincount(ids[ids != -1], minlength=ngroup) else: out = [] return Series(out, inde...
def size(self): """ Compute group sizes """ ids, _, ngroup = self.group_info ids = ensure_platform_int(ids) if ngroup: out = np.bincount(ids[ids != -1], minlength=ngroup) else: out = [] return Series(out, inde...
[ "Compute", "group", "sizes" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/ops.py#L241-L254
[ "def", "size", "(", "self", ")", ":", "ids", ",", "_", ",", "ngroup", "=", "self", ".", "group_info", "ids", "=", "ensure_platform_int", "(", "ids", ")", "if", "ngroup", ":", "out", "=", "np", ".", "bincount", "(", "ids", "[", "ids", "!=", "-", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BaseGrouper.groups
dict {group name -> group labels}
pandas/core/groupby/ops.py
def groups(self): """ dict {group name -> group labels} """ if len(self.groupings) == 1: return self.groupings[0].groups else: to_groupby = lzip(*(ping.grouper for ping in self.groupings)) to_groupby = Index(to_groupby) return self.axis.groupby(to_...
def groups(self): """ dict {group name -> group labels} """ if len(self.groupings) == 1: return self.groupings[0].groups else: to_groupby = lzip(*(ping.grouper for ping in self.groupings)) to_groupby = Index(to_groupby) return self.axis.groupby(to_...
[ "dict", "{", "group", "name", "-", ">", "group", "labels", "}" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/ops.py#L257-L264
[ "def", "groups", "(", "self", ")", ":", "if", "len", "(", "self", ".", "groupings", ")", "==", "1", ":", "return", "self", ".", "groupings", "[", "0", "]", ".", "groups", "else", ":", "to_groupby", "=", "lzip", "(", "*", "(", "ping", ".", "groupe...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BinGrouper.groups
dict {group name -> group labels}
pandas/core/groupby/ops.py
def groups(self): """ dict {group name -> group labels} """ # this is mainly for compat # GH 3881 result = {key: value for key, value in zip(self.binlabels, self.bins) if key is not NaT} return result
def groups(self): """ dict {group name -> group labels} """ # this is mainly for compat # GH 3881 result = {key: value for key, value in zip(self.binlabels, self.bins) if key is not NaT} return result
[ "dict", "{", "group", "name", "-", ">", "group", "labels", "}" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/ops.py#L698-L705
[ "def", "groups", "(", "self", ")", ":", "# this is mainly for compat", "# GH 3881", "result", "=", "{", "key", ":", "value", "for", "key", ",", "value", "in", "zip", "(", "self", ".", "binlabels", ",", "self", ".", "bins", ")", "if", "key", "is", "not"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BinGrouper.get_iterator
Groupby iterator Returns ------- Generator yielding sequence of (name, subsetted object) for each group
pandas/core/groupby/ops.py
def get_iterator(self, data, axis=0): """ Groupby iterator Returns ------- Generator yielding sequence of (name, subsetted object) for each group """ if isinstance(data, NDFrame): slicer = lambda start, edge: data._slice( slice...
def get_iterator(self, data, axis=0): """ Groupby iterator Returns ------- Generator yielding sequence of (name, subsetted object) for each group """ if isinstance(data, NDFrame): slicer = lambda start, edge: data._slice( slice...
[ "Groupby", "iterator" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/ops.py#L711-L735
[ "def", "get_iterator", "(", "self", ",", "data", ",", "axis", "=", "0", ")", ":", "if", "isinstance", "(", "data", ",", "NDFrame", ")", ":", "slicer", "=", "lambda", "start", ",", "edge", ":", "data", ".", "_slice", "(", "slice", "(", "start", ",",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
json_normalize
Normalize semi-structured JSON data into a flat table. Parameters ---------- data : dict or list of dicts Unserialized JSON objects record_path : string or list of strings, default None Path in each object to list of records. If not passed, data will be assumed to be an array of...
pandas/io/json/normalize.py
def json_normalize(data, record_path=None, meta=None, meta_prefix=None, record_prefix=None, errors='raise', sep='.'): """ Normalize semi-structured JSON data into a flat table. Parameters ---------- data : dict or list of d...
def json_normalize(data, record_path=None, meta=None, meta_prefix=None, record_prefix=None, errors='raise', sep='.'): """ Normalize semi-structured JSON data into a flat table. Parameters ---------- data : dict or list of d...
[ "Normalize", "semi", "-", "structured", "JSON", "data", "into", "a", "flat", "table", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/normalize.py#L99-L286
[ "def", "json_normalize", "(", "data", ",", "record_path", "=", "None", ",", "meta", "=", "None", ",", "meta_prefix", "=", "None", ",", "record_prefix", "=", "None", ",", "errors", "=", "'raise'", ",", "sep", "=", "'.'", ")", ":", "def", "_pull_field", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
lreshape
Reshape long-format data to wide. Generalized inverse of DataFrame.pivot Parameters ---------- data : DataFrame groups : dict {new_name : list_of_columns} dropna : boolean, default True Examples -------- >>> data = pd.DataFrame({'hr1': [514, 573], 'hr2': [545, 526], ... ...
pandas/core/reshape/melt.py
def lreshape(data, groups, dropna=True, label=None): """ Reshape long-format data to wide. Generalized inverse of DataFrame.pivot Parameters ---------- data : DataFrame groups : dict {new_name : list_of_columns} dropna : boolean, default True Examples -------- >>> data ...
def lreshape(data, groups, dropna=True, label=None): """ Reshape long-format data to wide. Generalized inverse of DataFrame.pivot Parameters ---------- data : DataFrame groups : dict {new_name : list_of_columns} dropna : boolean, default True Examples -------- >>> data ...
[ "Reshape", "long", "-", "format", "data", "to", "wide", ".", "Generalized", "inverse", "of", "DataFrame", ".", "pivot" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/melt.py#L108-L175
[ "def", "lreshape", "(", "data", ",", "groups", ",", "dropna", "=", "True", ",", "label", "=", "None", ")", ":", "if", "isinstance", "(", "groups", ",", "dict", ")", ":", "keys", "=", "list", "(", "groups", ".", "keys", "(", ")", ")", "values", "=...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
wide_to_long
r""" Wide panel to long format. Less flexible but more user-friendly than melt. With stubnames ['A', 'B'], this function expects to find one or more group of columns with format A-suffix1, A-suffix2,..., B-suffix1, B-suffix2,... You specify what you want to call this suffix in the resulting long fo...
pandas/core/reshape/melt.py
def wide_to_long(df, stubnames, i, j, sep="", suffix=r'\d+'): r""" Wide panel to long format. Less flexible but more user-friendly than melt. With stubnames ['A', 'B'], this function expects to find one or more group of columns with format A-suffix1, A-suffix2,..., B-suffix1, B-suffix2,... You ...
def wide_to_long(df, stubnames, i, j, sep="", suffix=r'\d+'): r""" Wide panel to long format. Less flexible but more user-friendly than melt. With stubnames ['A', 'B'], this function expects to find one or more group of columns with format A-suffix1, A-suffix2,..., B-suffix1, B-suffix2,... You ...
[ "r", "Wide", "panel", "to", "long", "format", ".", "Less", "flexible", "but", "more", "user", "-", "friendly", "than", "melt", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/melt.py#L178-L458
[ "def", "wide_to_long", "(", "df", ",", "stubnames", ",", "i", ",", "j", ",", "sep", "=", "\"\"", ",", "suffix", "=", "r'\\d+'", ")", ":", "def", "get_var_names", "(", "df", ",", "stub", ",", "sep", ",", "suffix", ")", ":", "regex", "=", "r'^{stub}{...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_GroupBy._get_indices
Safe get multiple indices, translate keys for datelike to underlying repr.
pandas/core/groupby/groupby.py
def _get_indices(self, names): """ Safe get multiple indices, translate keys for datelike to underlying repr. """ def get_converter(s): # possibly convert to the actual key types # in the indices, could be a Timestamp or a np.datetime64 if isi...
def _get_indices(self, names): """ Safe get multiple indices, translate keys for datelike to underlying repr. """ def get_converter(s): # possibly convert to the actual key types # in the indices, could be a Timestamp or a np.datetime64 if isi...
[ "Safe", "get", "multiple", "indices", "translate", "keys", "for", "datelike", "to", "underlying", "repr", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L409-L457
[ "def", "_get_indices", "(", "self", ",", "names", ")", ":", "def", "get_converter", "(", "s", ")", ":", "# possibly convert to the actual key types", "# in the indices, could be a Timestamp or a np.datetime64", "if", "isinstance", "(", "s", ",", "(", "Timestamp", ",", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_GroupBy._set_group_selection
Create group based selection. Used when selection is not passed directly but instead via a grouper. NOTE: this should be paired with a call to _reset_group_selection
pandas/core/groupby/groupby.py
def _set_group_selection(self): """ Create group based selection. Used when selection is not passed directly but instead via a grouper. NOTE: this should be paired with a call to _reset_group_selection """ grp = self.grouper if not (self.as_index and ...
def _set_group_selection(self): """ Create group based selection. Used when selection is not passed directly but instead via a grouper. NOTE: this should be paired with a call to _reset_group_selection """ grp = self.grouper if not (self.as_index and ...
[ "Create", "group", "based", "selection", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L487-L510
[ "def", "_set_group_selection", "(", "self", ")", ":", "grp", "=", "self", ".", "grouper", "if", "not", "(", "self", ".", "as_index", "and", "getattr", "(", "grp", ",", "'groupings'", ",", "None", ")", "is", "not", "None", "and", "self", ".", "obj", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_GroupBy.get_group
Construct NDFrame from group with provided name. Parameters ---------- name : object the name of the group to get as a DataFrame obj : NDFrame, default None the NDFrame to take the DataFrame out of. If it is None, the object groupby was called on wil...
pandas/core/groupby/groupby.py
def get_group(self, name, obj=None): """ Construct NDFrame from group with provided name. Parameters ---------- name : object the name of the group to get as a DataFrame obj : NDFrame, default None the NDFrame to take the DataFrame out of. If ...
def get_group(self, name, obj=None): """ Construct NDFrame from group with provided name. Parameters ---------- name : object the name of the group to get as a DataFrame obj : NDFrame, default None the NDFrame to take the DataFrame out of. If ...
[ "Construct", "NDFrame", "from", "group", "with", "provided", "name", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L630-L654
[ "def", "get_group", "(", "self", ",", "name", ",", "obj", "=", "None", ")", ":", "if", "obj", "is", "None", ":", "obj", "=", "self", ".", "_selected_obj", "inds", "=", "self", ".", "_get_index", "(", "name", ")", "if", "not", "len", "(", "inds", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_GroupBy._cumcount_array
Parameters ---------- ascending : bool, default True If False, number in reverse, from length of group - 1 to 0. Notes ----- this is currently implementing sort=False (though the default is sort=True) for groupby in general
pandas/core/groupby/groupby.py
def _cumcount_array(self, ascending=True): """ Parameters ---------- ascending : bool, default True If False, number in reverse, from length of group - 1 to 0. Notes ----- this is currently implementing sort=False (though the default is sort=T...
def _cumcount_array(self, ascending=True): """ Parameters ---------- ascending : bool, default True If False, number in reverse, from length of group - 1 to 0. Notes ----- this is currently implementing sort=False (though the default is sort=T...
[ "Parameters", "----------", "ascending", ":", "bool", "default", "True", "If", "False", "number", "in", "reverse", "from", "length", "of", "group", "-", "1", "to", "0", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L724-L754
[ "def", "_cumcount_array", "(", "self", ",", "ascending", "=", "True", ")", ":", "ids", ",", "_", ",", "ngroups", "=", "self", ".", "grouper", ".", "group_info", "sorter", "=", "get_group_index_sorter", "(", "ids", ",", "ngroups", ")", "ids", ",", "count"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_GroupBy._try_cast
Try to cast the result to our obj original type, we may have roundtripped through object in the mean-time. If numeric_only is True, then only try to cast numerics and not datetimelikes.
pandas/core/groupby/groupby.py
def _try_cast(self, result, obj, numeric_only=False): """ Try to cast the result to our obj original type, we may have roundtripped through object in the mean-time. If numeric_only is True, then only try to cast numerics and not datetimelikes. """ if obj.ndim > ...
def _try_cast(self, result, obj, numeric_only=False): """ Try to cast the result to our obj original type, we may have roundtripped through object in the mean-time. If numeric_only is True, then only try to cast numerics and not datetimelikes. """ if obj.ndim > ...
[ "Try", "to", "cast", "the", "result", "to", "our", "obj", "original", "type", "we", "may", "have", "roundtripped", "through", "object", "in", "the", "mean", "-", "time", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L756-L799
[ "def", "_try_cast", "(", "self", ",", "result", ",", "obj", ",", "numeric_only", "=", "False", ")", ":", "if", "obj", ".", "ndim", ">", "1", ":", "dtype", "=", "obj", ".", "_values", ".", "dtype", "else", ":", "dtype", "=", "obj", ".", "dtype", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_GroupBy._transform_should_cast
Parameters: ----------- func_nm: str The name of the aggregation function being performed Returns: -------- bool Whether transform should attempt to cast the result of aggregation
pandas/core/groupby/groupby.py
def _transform_should_cast(self, func_nm): """ Parameters: ----------- func_nm: str The name of the aggregation function being performed Returns: -------- bool Whether transform should attempt to cast the result of aggregation """ ...
def _transform_should_cast(self, func_nm): """ Parameters: ----------- func_nm: str The name of the aggregation function being performed Returns: -------- bool Whether transform should attempt to cast the result of aggregation """ ...
[ "Parameters", ":", "-----------", "func_nm", ":", "str", "The", "name", "of", "the", "aggregation", "function", "being", "performed" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L801-L814
[ "def", "_transform_should_cast", "(", "self", ",", "func_nm", ")", ":", "return", "(", "self", ".", "size", "(", ")", ".", "fillna", "(", "0", ")", ">", "0", ")", ".", "any", "(", ")", "and", "(", "func_nm", "not", "in", "base", ".", "cython_cast_b...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy._bool_agg
Shared func to call any / all Cython GroupBy implementations.
pandas/core/groupby/groupby.py
def _bool_agg(self, val_test, skipna): """ Shared func to call any / all Cython GroupBy implementations. """ def objs_to_bool(vals: np.ndarray) -> Tuple[np.ndarray, Type]: if is_object_dtype(vals): vals = np.array([bool(x) for x in vals]) else: ...
def _bool_agg(self, val_test, skipna): """ Shared func to call any / all Cython GroupBy implementations. """ def objs_to_bool(vals: np.ndarray) -> Tuple[np.ndarray, Type]: if is_object_dtype(vals): vals = np.array([bool(x) for x in vals]) else: ...
[ "Shared", "func", "to", "call", "any", "/", "all", "Cython", "GroupBy", "implementations", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1039-L1062
[ "def", "_bool_agg", "(", "self", ",", "val_test", ",", "skipna", ")", ":", "def", "objs_to_bool", "(", "vals", ":", "np", ".", "ndarray", ")", "->", "Tuple", "[", "np", ".", "ndarray", ",", "Type", "]", ":", "if", "is_object_dtype", "(", "vals", ")",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.mean
Compute mean of groups, excluding missing values. Returns ------- pandas.Series or pandas.DataFrame %(see_also)s Examples -------- >>> df = pd.DataFrame({'A': [1, 1, 2, 1, 2], ... 'B': [np.nan, 2, 3, 4, 5], ... ...
pandas/core/groupby/groupby.py
def mean(self, *args, **kwargs): """ Compute mean of groups, excluding missing values. Returns ------- pandas.Series or pandas.DataFrame %(see_also)s Examples -------- >>> df = pd.DataFrame({'A': [1, 1, 2, 1, 2], ... 'B'...
def mean(self, *args, **kwargs): """ Compute mean of groups, excluding missing values. Returns ------- pandas.Series or pandas.DataFrame %(see_also)s Examples -------- >>> df = pd.DataFrame({'A': [1, 1, 2, 1, 2], ... 'B'...
[ "Compute", "mean", "of", "groups", "excluding", "missing", "values", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1102-L1155
[ "def", "mean", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "nv", ".", "validate_groupby_func", "(", "'mean'", ",", "args", ",", "kwargs", ",", "[", "'numeric_only'", "]", ")", "try", ":", "return", "self", ".", "_cython_agg_genera...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.median
Compute median of groups, excluding missing values. For multiple groupings, the result index will be a MultiIndex
pandas/core/groupby/groupby.py
def median(self, **kwargs): """ Compute median of groups, excluding missing values. For multiple groupings, the result index will be a MultiIndex """ try: return self._cython_agg_general('median', **kwargs) except GroupByError: raise excep...
def median(self, **kwargs): """ Compute median of groups, excluding missing values. For multiple groupings, the result index will be a MultiIndex """ try: return self._cython_agg_general('median', **kwargs) except GroupByError: raise excep...
[ "Compute", "median", "of", "groups", "excluding", "missing", "values", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1159-L1176
[ "def", "median", "(", "self", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "self", ".", "_cython_agg_general", "(", "'median'", ",", "*", "*", "kwargs", ")", "except", "GroupByError", ":", "raise", "except", "Exception", ":", "# pragma: no cove...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.std
Compute standard deviation of groups, excluding missing values. For multiple groupings, the result index will be a MultiIndex. Parameters ---------- ddof : integer, default 1 degrees of freedom
pandas/core/groupby/groupby.py
def std(self, ddof=1, *args, **kwargs): """ Compute standard deviation of groups, excluding missing values. For multiple groupings, the result index will be a MultiIndex. Parameters ---------- ddof : integer, default 1 degrees of freedom """ ...
def std(self, ddof=1, *args, **kwargs): """ Compute standard deviation of groups, excluding missing values. For multiple groupings, the result index will be a MultiIndex. Parameters ---------- ddof : integer, default 1 degrees of freedom """ ...
[ "Compute", "standard", "deviation", "of", "groups", "excluding", "missing", "values", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1180-L1194
[ "def", "std", "(", "self", ",", "ddof", "=", "1", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# TODO: implement at Cython level?", "nv", ".", "validate_groupby_func", "(", "'std'", ",", "args", ",", "kwargs", ")", "return", "np", ".", "sqrt", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.var
Compute variance of groups, excluding missing values. For multiple groupings, the result index will be a MultiIndex. Parameters ---------- ddof : integer, default 1 degrees of freedom
pandas/core/groupby/groupby.py
def var(self, ddof=1, *args, **kwargs): """ Compute variance of groups, excluding missing values. For multiple groupings, the result index will be a MultiIndex. Parameters ---------- ddof : integer, default 1 degrees of freedom """ nv.validat...
def var(self, ddof=1, *args, **kwargs): """ Compute variance of groups, excluding missing values. For multiple groupings, the result index will be a MultiIndex. Parameters ---------- ddof : integer, default 1 degrees of freedom """ nv.validat...
[ "Compute", "variance", "of", "groups", "excluding", "missing", "values", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1198-L1220
[ "def", "var", "(", "self", ",", "ddof", "=", "1", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "nv", ".", "validate_groupby_func", "(", "'var'", ",", "args", ",", "kwargs", ")", "if", "ddof", "==", "1", ":", "try", ":", "return", "self", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.sem
Compute standard error of the mean of groups, excluding missing values. For multiple groupings, the result index will be a MultiIndex. Parameters ---------- ddof : integer, default 1 degrees of freedom
pandas/core/groupby/groupby.py
def sem(self, ddof=1): """ Compute standard error of the mean of groups, excluding missing values. For multiple groupings, the result index will be a MultiIndex. Parameters ---------- ddof : integer, default 1 degrees of freedom """ return s...
def sem(self, ddof=1): """ Compute standard error of the mean of groups, excluding missing values. For multiple groupings, the result index will be a MultiIndex. Parameters ---------- ddof : integer, default 1 degrees of freedom """ return s...
[ "Compute", "standard", "error", "of", "the", "mean", "of", "groups", "excluding", "missing", "values", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1224-L1236
[ "def", "sem", "(", "self", ",", "ddof", "=", "1", ")", ":", "return", "self", ".", "std", "(", "ddof", "=", "ddof", ")", "/", "np", ".", "sqrt", "(", "self", ".", "count", "(", ")", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.size
Compute group sizes.
pandas/core/groupby/groupby.py
def size(self): """ Compute group sizes. """ result = self.grouper.size() if isinstance(self.obj, Series): result.name = getattr(self.obj, 'name', None) return result
def size(self): """ Compute group sizes. """ result = self.grouper.size() if isinstance(self.obj, Series): result.name = getattr(self.obj, 'name', None) return result
[ "Compute", "group", "sizes", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1240-L1248
[ "def", "size", "(", "self", ")", ":", "result", "=", "self", ".", "grouper", ".", "size", "(", ")", "if", "isinstance", "(", "self", ".", "obj", ",", "Series", ")", ":", "result", ".", "name", "=", "getattr", "(", "self", ".", "obj", ",", "'name'...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy._add_numeric_operations
Add numeric operations to the GroupBy generically.
pandas/core/groupby/groupby.py
def _add_numeric_operations(cls): """ Add numeric operations to the GroupBy generically. """ def groupby_function(name, alias, npfunc, numeric_only=True, _convert=False, min_count=-1): _local_template = "Compute %(f)...
def _add_numeric_operations(cls): """ Add numeric operations to the GroupBy generically. """ def groupby_function(name, alias, npfunc, numeric_only=True, _convert=False, min_count=-1): _local_template = "Compute %(f)...
[ "Add", "numeric", "operations", "to", "the", "GroupBy", "generically", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1251-L1324
[ "def", "_add_numeric_operations", "(", "cls", ")", ":", "def", "groupby_function", "(", "name", ",", "alias", ",", "npfunc", ",", "numeric_only", "=", "True", ",", "_convert", "=", "False", ",", "min_count", "=", "-", "1", ")", ":", "_local_template", "=",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.resample
Provide resampling when using a TimeGrouper. Given a grouper, the function resamples it according to a string "string" -> "frequency". See the :ref:`frequency aliases <timeseries.offset_aliases>` documentation for more details. Parameters ---------- rule : str ...
pandas/core/groupby/groupby.py
def resample(self, rule, *args, **kwargs): """ Provide resampling when using a TimeGrouper. Given a grouper, the function resamples it according to a string "string" -> "frequency". See the :ref:`frequency aliases <timeseries.offset_aliases>` documentation for more deta...
def resample(self, rule, *args, **kwargs): """ Provide resampling when using a TimeGrouper. Given a grouper, the function resamples it according to a string "string" -> "frequency". See the :ref:`frequency aliases <timeseries.offset_aliases>` documentation for more deta...
[ "Provide", "resampling", "when", "using", "a", "TimeGrouper", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1346-L1453
[ "def", "resample", "(", "self", ",", "rule", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "pandas", ".", "core", ".", "resample", "import", "get_resampler_for_grouping", "return", "get_resampler_for_grouping", "(", "self", ",", "rule", ",", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.rolling
Return a rolling grouper, providing rolling functionality per group.
pandas/core/groupby/groupby.py
def rolling(self, *args, **kwargs): """ Return a rolling grouper, providing rolling functionality per group. """ from pandas.core.window import RollingGroupby return RollingGroupby(self, *args, **kwargs)
def rolling(self, *args, **kwargs): """ Return a rolling grouper, providing rolling functionality per group. """ from pandas.core.window import RollingGroupby return RollingGroupby(self, *args, **kwargs)
[ "Return", "a", "rolling", "grouper", "providing", "rolling", "functionality", "per", "group", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1457-L1462
[ "def", "rolling", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "pandas", ".", "core", ".", "window", "import", "RollingGroupby", "return", "RollingGroupby", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.expanding
Return an expanding grouper, providing expanding functionality per group.
pandas/core/groupby/groupby.py
def expanding(self, *args, **kwargs): """ Return an expanding grouper, providing expanding functionality per group. """ from pandas.core.window import ExpandingGroupby return ExpandingGroupby(self, *args, **kwargs)
def expanding(self, *args, **kwargs): """ Return an expanding grouper, providing expanding functionality per group. """ from pandas.core.window import ExpandingGroupby return ExpandingGroupby(self, *args, **kwargs)
[ "Return", "an", "expanding", "grouper", "providing", "expanding", "functionality", "per", "group", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1466-L1472
[ "def", "expanding", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "pandas", ".", "core", ".", "window", "import", "ExpandingGroupby", "return", "ExpandingGroupby", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")" ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy._fill
Shared function for `pad` and `backfill` to call Cython method. Parameters ---------- direction : {'ffill', 'bfill'} Direction passed to underlying Cython function. `bfill` will cause values to be filled backwards. `ffill` and any other values will default to...
pandas/core/groupby/groupby.py
def _fill(self, direction, limit=None): """ Shared function for `pad` and `backfill` to call Cython method. Parameters ---------- direction : {'ffill', 'bfill'} Direction passed to underlying Cython function. `bfill` will cause values to be filled backwar...
def _fill(self, direction, limit=None): """ Shared function for `pad` and `backfill` to call Cython method. Parameters ---------- direction : {'ffill', 'bfill'} Direction passed to underlying Cython function. `bfill` will cause values to be filled backwar...
[ "Shared", "function", "for", "pad", "and", "backfill", "to", "call", "Cython", "method", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1474-L1505
[ "def", "_fill", "(", "self", ",", "direction", ",", "limit", "=", "None", ")", ":", "# Need int value for Cython", "if", "limit", "is", "None", ":", "limit", "=", "-", "1", "return", "self", ".", "_get_cythonized_result", "(", "'group_fillna_indexer'", ",", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.nth
Take the nth row from each group if n is an int, or a subset of rows if n is a list of ints. If dropna, will take the nth non-null row, dropna is either Truthy (if a Series) or 'all', 'any' (if a DataFrame); this is equivalent to calling dropna(how=dropna) before the groupby. ...
pandas/core/groupby/groupby.py
def nth(self, n, dropna=None): """ Take the nth row from each group if n is an int, or a subset of rows if n is a list of ints. If dropna, will take the nth non-null row, dropna is either Truthy (if a Series) or 'all', 'any' (if a DataFrame); this is equivalent to callin...
def nth(self, n, dropna=None): """ Take the nth row from each group if n is an int, or a subset of rows if n is a list of ints. If dropna, will take the nth non-null row, dropna is either Truthy (if a Series) or 'all', 'any' (if a DataFrame); this is equivalent to callin...
[ "Take", "the", "nth", "row", "from", "each", "group", "if", "n", "is", "an", "int", "or", "a", "subset", "of", "rows", "if", "n", "is", "a", "list", "of", "ints", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1549-L1705
[ "def", "nth", "(", "self", ",", "n", ",", "dropna", "=", "None", ")", ":", "if", "isinstance", "(", "n", ",", "int", ")", ":", "nth_values", "=", "[", "n", "]", "elif", "isinstance", "(", "n", ",", "(", "set", ",", "list", ",", "tuple", ")", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.quantile
Return group values at the given quantile, a la numpy.percentile. Parameters ---------- q : float or array-like, default 0.5 (50% quantile) Value(s) between 0 and 1 providing the quantile(s) to compute. interpolation : {'linear', 'lower', 'higher', 'midpoint', 'nearest'} ...
pandas/core/groupby/groupby.py
def quantile(self, q=0.5, interpolation='linear'): """ Return group values at the given quantile, a la numpy.percentile. Parameters ---------- q : float or array-like, default 0.5 (50% quantile) Value(s) between 0 and 1 providing the quantile(s) to compute. i...
def quantile(self, q=0.5, interpolation='linear'): """ Return group values at the given quantile, a la numpy.percentile. Parameters ---------- q : float or array-like, default 0.5 (50% quantile) Value(s) between 0 and 1 providing the quantile(s) to compute. i...
[ "Return", "group", "values", "at", "the", "given", "quantile", "a", "la", "numpy", ".", "percentile", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1707-L1777
[ "def", "quantile", "(", "self", ",", "q", "=", "0.5", ",", "interpolation", "=", "'linear'", ")", ":", "def", "pre_processor", "(", "vals", ":", "np", ".", "ndarray", ")", "->", "Tuple", "[", "np", ".", "ndarray", ",", "Optional", "[", "Type", "]", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.ngroup
Number each group from 0 to the number of groups - 1. This is the enumerative complement of cumcount. Note that the numbers given to the groups match the order in which the groups would be seen when iterating over the groupby object, not the order they are first observed. .. v...
pandas/core/groupby/groupby.py
def ngroup(self, ascending=True): """ Number each group from 0 to the number of groups - 1. This is the enumerative complement of cumcount. Note that the numbers given to the groups match the order in which the groups would be seen when iterating over the groupby object, not th...
def ngroup(self, ascending=True): """ Number each group from 0 to the number of groups - 1. This is the enumerative complement of cumcount. Note that the numbers given to the groups match the order in which the groups would be seen when iterating over the groupby object, not th...
[ "Number", "each", "group", "from", "0", "to", "the", "number", "of", "groups", "-", "1", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1780-L1843
[ "def", "ngroup", "(", "self", ",", "ascending", "=", "True", ")", ":", "with", "_group_selection_context", "(", "self", ")", ":", "index", "=", "self", ".", "_selected_obj", ".", "index", "result", "=", "Series", "(", "self", ".", "grouper", ".", "group_...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.cumcount
Number each item in each group from 0 to the length of that group - 1. Essentially this is equivalent to >>> self.apply(lambda x: pd.Series(np.arange(len(x)), x.index)) Parameters ---------- ascending : bool, default True If False, number in reverse, from length of...
pandas/core/groupby/groupby.py
def cumcount(self, ascending=True): """ Number each item in each group from 0 to the length of that group - 1. Essentially this is equivalent to >>> self.apply(lambda x: pd.Series(np.arange(len(x)), x.index)) Parameters ---------- ascending : bool, default True...
def cumcount(self, ascending=True): """ Number each item in each group from 0 to the length of that group - 1. Essentially this is equivalent to >>> self.apply(lambda x: pd.Series(np.arange(len(x)), x.index)) Parameters ---------- ascending : bool, default True...
[ "Number", "each", "item", "in", "each", "group", "from", "0", "to", "the", "length", "of", "that", "group", "-", "1", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1846-L1897
[ "def", "cumcount", "(", "self", ",", "ascending", "=", "True", ")", ":", "with", "_group_selection_context", "(", "self", ")", ":", "index", "=", "self", ".", "_selected_obj", ".", "index", "cumcounts", "=", "self", ".", "_cumcount_array", "(", "ascending", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.rank
Provide the rank of values within each group. Parameters ---------- method : {'average', 'min', 'max', 'first', 'dense'}, default 'average' * average: average rank of group * min: lowest rank in group * max: highest rank in group * first: ranks as...
pandas/core/groupby/groupby.py
def rank(self, method='average', ascending=True, na_option='keep', pct=False, axis=0): """ Provide the rank of values within each group. Parameters ---------- method : {'average', 'min', 'max', 'first', 'dense'}, default 'average' * average: average rank...
def rank(self, method='average', ascending=True, na_option='keep', pct=False, axis=0): """ Provide the rank of values within each group. Parameters ---------- method : {'average', 'min', 'max', 'first', 'dense'}, default 'average' * average: average rank...
[ "Provide", "the", "rank", "of", "values", "within", "each", "group", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1901-L1934
[ "def", "rank", "(", "self", ",", "method", "=", "'average'", ",", "ascending", "=", "True", ",", "na_option", "=", "'keep'", ",", "pct", "=", "False", ",", "axis", "=", "0", ")", ":", "if", "na_option", "not", "in", "{", "'keep'", ",", "'top'", ","...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.cumprod
Cumulative product for each group.
pandas/core/groupby/groupby.py
def cumprod(self, axis=0, *args, **kwargs): """ Cumulative product for each group. """ nv.validate_groupby_func('cumprod', args, kwargs, ['numeric_only', 'skipna']) if axis != 0: return self.apply(lambda x: x.cumprod(axis=axis, **kwarg...
def cumprod(self, axis=0, *args, **kwargs): """ Cumulative product for each group. """ nv.validate_groupby_func('cumprod', args, kwargs, ['numeric_only', 'skipna']) if axis != 0: return self.apply(lambda x: x.cumprod(axis=axis, **kwarg...
[ "Cumulative", "product", "for", "each", "group", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1938-L1947
[ "def", "cumprod", "(", "self", ",", "axis", "=", "0", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "nv", ".", "validate_groupby_func", "(", "'cumprod'", ",", "args", ",", "kwargs", ",", "[", "'numeric_only'", ",", "'skipna'", "]", ")", "if", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.cummin
Cumulative min for each group.
pandas/core/groupby/groupby.py
def cummin(self, axis=0, **kwargs): """ Cumulative min for each group. """ if axis != 0: return self.apply(lambda x: np.minimum.accumulate(x, axis)) return self._cython_transform('cummin', numeric_only=False)
def cummin(self, axis=0, **kwargs): """ Cumulative min for each group. """ if axis != 0: return self.apply(lambda x: np.minimum.accumulate(x, axis)) return self._cython_transform('cummin', numeric_only=False)
[ "Cumulative", "min", "for", "each", "group", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1964-L1971
[ "def", "cummin", "(", "self", ",", "axis", "=", "0", ",", "*", "*", "kwargs", ")", ":", "if", "axis", "!=", "0", ":", "return", "self", ".", "apply", "(", "lambda", "x", ":", "np", ".", "minimum", ".", "accumulate", "(", "x", ",", "axis", ")", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.cummax
Cumulative max for each group.
pandas/core/groupby/groupby.py
def cummax(self, axis=0, **kwargs): """ Cumulative max for each group. """ if axis != 0: return self.apply(lambda x: np.maximum.accumulate(x, axis)) return self._cython_transform('cummax', numeric_only=False)
def cummax(self, axis=0, **kwargs): """ Cumulative max for each group. """ if axis != 0: return self.apply(lambda x: np.maximum.accumulate(x, axis)) return self._cython_transform('cummax', numeric_only=False)
[ "Cumulative", "max", "for", "each", "group", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1975-L1982
[ "def", "cummax", "(", "self", ",", "axis", "=", "0", ",", "*", "*", "kwargs", ")", ":", "if", "axis", "!=", "0", ":", "return", "self", ".", "apply", "(", "lambda", "x", ":", "np", ".", "maximum", ".", "accumulate", "(", "x", ",", "axis", ")", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy._get_cythonized_result
Get result for Cythonized functions. Parameters ---------- how : str, Cythonized function name to be called grouper : Grouper object containing pertinent group info aggregate : bool, default False Whether the result should be aggregated to match the number of ...
pandas/core/groupby/groupby.py
def _get_cythonized_result(self, how, grouper, aggregate=False, cython_dtype=None, needs_values=False, needs_mask=False, needs_ngroups=False, result_is_index=False, pre_processing=None, post_proce...
def _get_cythonized_result(self, how, grouper, aggregate=False, cython_dtype=None, needs_values=False, needs_mask=False, needs_ngroups=False, result_is_index=False, pre_processing=None, post_proce...
[ "Get", "result", "for", "Cythonized", "functions", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1984-L2088
[ "def", "_get_cythonized_result", "(", "self", ",", "how", ",", "grouper", ",", "aggregate", "=", "False", ",", "cython_dtype", "=", "None", ",", "needs_values", "=", "False", ",", "needs_mask", "=", "False", ",", "needs_ngroups", "=", "False", ",", "result_i...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.shift
Shift each group by periods observations. Parameters ---------- periods : integer, default 1 number of periods to shift freq : frequency string axis : axis to shift, default 0 fill_value : optional .. versionadded:: 0.24.0
pandas/core/groupby/groupby.py
def shift(self, periods=1, freq=None, axis=0, fill_value=None): """ Shift each group by periods observations. Parameters ---------- periods : integer, default 1 number of periods to shift freq : frequency string axis : axis to shift, default 0 ...
def shift(self, periods=1, freq=None, axis=0, fill_value=None): """ Shift each group by periods observations. Parameters ---------- periods : integer, default 1 number of periods to shift freq : frequency string axis : axis to shift, default 0 ...
[ "Shift", "each", "group", "by", "periods", "observations", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L2092-L2115
[ "def", "shift", "(", "self", ",", "periods", "=", "1", ",", "freq", "=", "None", ",", "axis", "=", "0", ",", "fill_value", "=", "None", ")", ":", "if", "freq", "is", "not", "None", "or", "axis", "!=", "0", "or", "not", "isna", "(", "fill_value", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.head
Return first n rows of each group. Essentially equivalent to ``.apply(lambda x: x.head(n))``, except ignores as_index flag. %(see_also)s Examples -------- >>> df = pd.DataFrame([[1, 2], [1, 4], [5, 6]], columns=['A', 'B']) >>> df.gr...
pandas/core/groupby/groupby.py
def head(self, n=5): """ Return first n rows of each group. Essentially equivalent to ``.apply(lambda x: x.head(n))``, except ignores as_index flag. %(see_also)s Examples -------- >>> df = pd.DataFrame([[1, 2], [1, 4], [5, 6]], ...
def head(self, n=5): """ Return first n rows of each group. Essentially equivalent to ``.apply(lambda x: x.head(n))``, except ignores as_index flag. %(see_also)s Examples -------- >>> df = pd.DataFrame([[1, 2], [1, 4], [5, 6]], ...
[ "Return", "first", "n", "rows", "of", "each", "group", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L2137-L2160
[ "def", "head", "(", "self", ",", "n", "=", "5", ")", ":", "self", ".", "_reset_group_selection", "(", ")", "mask", "=", "self", ".", "_cumcount_array", "(", ")", "<", "n", "return", "self", ".", "_selected_obj", "[", "mask", "]" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupBy.tail
Return last n rows of each group. Essentially equivalent to ``.apply(lambda x: x.tail(n))``, except ignores as_index flag. %(see_also)s Examples -------- >>> df = pd.DataFrame([['a', 1], ['a', 2], ['b', 1], ['b', 2]], columns=['A', 'B']) ...
pandas/core/groupby/groupby.py
def tail(self, n=5): """ Return last n rows of each group. Essentially equivalent to ``.apply(lambda x: x.tail(n))``, except ignores as_index flag. %(see_also)s Examples -------- >>> df = pd.DataFrame([['a', 1], ['a', 2], ['b', 1], ['b', 2]], ...
def tail(self, n=5): """ Return last n rows of each group. Essentially equivalent to ``.apply(lambda x: x.tail(n))``, except ignores as_index flag. %(see_also)s Examples -------- >>> df = pd.DataFrame([['a', 1], ['a', 2], ['b', 1], ['b', 2]], ...
[ "Return", "last", "n", "rows", "of", "each", "group", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L2164-L2187
[ "def", "tail", "(", "self", ",", "n", "=", "5", ")", ":", "self", ".", "_reset_group_selection", "(", ")", "mask", "=", "self", ".", "_cumcount_array", "(", "ascending", "=", "False", ")", "<", "n", "return", "self", ".", "_selected_obj", "[", "mask", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
next_monday
If holiday falls on Saturday, use following Monday instead; if holiday falls on Sunday, use Monday instead
pandas/tseries/holiday.py
def next_monday(dt): """ If holiday falls on Saturday, use following Monday instead; if holiday falls on Sunday, use Monday instead """ if dt.weekday() == 5: return dt + timedelta(2) elif dt.weekday() == 6: return dt + timedelta(1) return dt
def next_monday(dt): """ If holiday falls on Saturday, use following Monday instead; if holiday falls on Sunday, use Monday instead """ if dt.weekday() == 5: return dt + timedelta(2) elif dt.weekday() == 6: return dt + timedelta(1) return dt
[ "If", "holiday", "falls", "on", "Saturday", "use", "following", "Monday", "instead", ";", "if", "holiday", "falls", "on", "Sunday", "use", "Monday", "instead" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L15-L24
[ "def", "next_monday", "(", "dt", ")", ":", "if", "dt", ".", "weekday", "(", ")", "==", "5", ":", "return", "dt", "+", "timedelta", "(", "2", ")", "elif", "dt", ".", "weekday", "(", ")", "==", "6", ":", "return", "dt", "+", "timedelta", "(", "1"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
next_monday_or_tuesday
For second holiday of two adjacent ones! If holiday falls on Saturday, use following Monday instead; if holiday falls on Sunday or Monday, use following Tuesday instead (because Monday is already taken by adjacent holiday on the day before)
pandas/tseries/holiday.py
def next_monday_or_tuesday(dt): """ For second holiday of two adjacent ones! If holiday falls on Saturday, use following Monday instead; if holiday falls on Sunday or Monday, use following Tuesday instead (because Monday is already taken by adjacent holiday on the day before) """ dow = dt.we...
def next_monday_or_tuesday(dt): """ For second holiday of two adjacent ones! If holiday falls on Saturday, use following Monday instead; if holiday falls on Sunday or Monday, use following Tuesday instead (because Monday is already taken by adjacent holiday on the day before) """ dow = dt.we...
[ "For", "second", "holiday", "of", "two", "adjacent", "ones!", "If", "holiday", "falls", "on", "Saturday", "use", "following", "Monday", "instead", ";", "if", "holiday", "falls", "on", "Sunday", "or", "Monday", "use", "following", "Tuesday", "instead", "(", "...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L27-L39
[ "def", "next_monday_or_tuesday", "(", "dt", ")", ":", "dow", "=", "dt", ".", "weekday", "(", ")", "if", "dow", "==", "5", "or", "dow", "==", "6", ":", "return", "dt", "+", "timedelta", "(", "2", ")", "elif", "dow", "==", "0", ":", "return", "dt",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
previous_friday
If holiday falls on Saturday or Sunday, use previous Friday instead.
pandas/tseries/holiday.py
def previous_friday(dt): """ If holiday falls on Saturday or Sunday, use previous Friday instead. """ if dt.weekday() == 5: return dt - timedelta(1) elif dt.weekday() == 6: return dt - timedelta(2) return dt
def previous_friday(dt): """ If holiday falls on Saturday or Sunday, use previous Friday instead. """ if dt.weekday() == 5: return dt - timedelta(1) elif dt.weekday() == 6: return dt - timedelta(2) return dt
[ "If", "holiday", "falls", "on", "Saturday", "or", "Sunday", "use", "previous", "Friday", "instead", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L42-L50
[ "def", "previous_friday", "(", "dt", ")", ":", "if", "dt", ".", "weekday", "(", ")", "==", "5", ":", "return", "dt", "-", "timedelta", "(", "1", ")", "elif", "dt", ".", "weekday", "(", ")", "==", "6", ":", "return", "dt", "-", "timedelta", "(", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
weekend_to_monday
If holiday falls on Sunday or Saturday, use day thereafter (Monday) instead. Needed for holidays such as Christmas observation in Europe
pandas/tseries/holiday.py
def weekend_to_monday(dt): """ If holiday falls on Sunday or Saturday, use day thereafter (Monday) instead. Needed for holidays such as Christmas observation in Europe """ if dt.weekday() == 6: return dt + timedelta(1) elif dt.weekday() == 5: return dt + timedelta(2) retu...
def weekend_to_monday(dt): """ If holiday falls on Sunday or Saturday, use day thereafter (Monday) instead. Needed for holidays such as Christmas observation in Europe """ if dt.weekday() == 6: return dt + timedelta(1) elif dt.weekday() == 5: return dt + timedelta(2) retu...
[ "If", "holiday", "falls", "on", "Sunday", "or", "Saturday", "use", "day", "thereafter", "(", "Monday", ")", "instead", ".", "Needed", "for", "holidays", "such", "as", "Christmas", "observation", "in", "Europe" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L62-L72
[ "def", "weekend_to_monday", "(", "dt", ")", ":", "if", "dt", ".", "weekday", "(", ")", "==", "6", ":", "return", "dt", "+", "timedelta", "(", "1", ")", "elif", "dt", ".", "weekday", "(", ")", "==", "5", ":", "return", "dt", "+", "timedelta", "(",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
nearest_workday
If holiday falls on Saturday, use day before (Friday) instead; if holiday falls on Sunday, use day thereafter (Monday) instead.
pandas/tseries/holiday.py
def nearest_workday(dt): """ If holiday falls on Saturday, use day before (Friday) instead; if holiday falls on Sunday, use day thereafter (Monday) instead. """ if dt.weekday() == 5: return dt - timedelta(1) elif dt.weekday() == 6: return dt + timedelta(1) return dt
def nearest_workday(dt): """ If holiday falls on Saturday, use day before (Friday) instead; if holiday falls on Sunday, use day thereafter (Monday) instead. """ if dt.weekday() == 5: return dt - timedelta(1) elif dt.weekday() == 6: return dt + timedelta(1) return dt
[ "If", "holiday", "falls", "on", "Saturday", "use", "day", "before", "(", "Friday", ")", "instead", ";", "if", "holiday", "falls", "on", "Sunday", "use", "day", "thereafter", "(", "Monday", ")", "instead", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L75-L84
[ "def", "nearest_workday", "(", "dt", ")", ":", "if", "dt", ".", "weekday", "(", ")", "==", "5", ":", "return", "dt", "-", "timedelta", "(", "1", ")", "elif", "dt", ".", "weekday", "(", ")", "==", "6", ":", "return", "dt", "+", "timedelta", "(", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
next_workday
returns next weekday used for observances
pandas/tseries/holiday.py
def next_workday(dt): """ returns next weekday used for observances """ dt += timedelta(days=1) while dt.weekday() > 4: # Mon-Fri are 0-4 dt += timedelta(days=1) return dt
def next_workday(dt): """ returns next weekday used for observances """ dt += timedelta(days=1) while dt.weekday() > 4: # Mon-Fri are 0-4 dt += timedelta(days=1) return dt
[ "returns", "next", "weekday", "used", "for", "observances" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L87-L95
[ "def", "next_workday", "(", "dt", ")", ":", "dt", "+=", "timedelta", "(", "days", "=", "1", ")", "while", "dt", ".", "weekday", "(", ")", ">", "4", ":", "# Mon-Fri are 0-4", "dt", "+=", "timedelta", "(", "days", "=", "1", ")", "return", "dt" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
previous_workday
returns previous weekday used for observances
pandas/tseries/holiday.py
def previous_workday(dt): """ returns previous weekday used for observances """ dt -= timedelta(days=1) while dt.weekday() > 4: # Mon-Fri are 0-4 dt -= timedelta(days=1) return dt
def previous_workday(dt): """ returns previous weekday used for observances """ dt -= timedelta(days=1) while dt.weekday() > 4: # Mon-Fri are 0-4 dt -= timedelta(days=1) return dt
[ "returns", "previous", "weekday", "used", "for", "observances" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L98-L106
[ "def", "previous_workday", "(", "dt", ")", ":", "dt", "-=", "timedelta", "(", "days", "=", "1", ")", "while", "dt", ".", "weekday", "(", ")", ">", "4", ":", "# Mon-Fri are 0-4", "dt", "-=", "timedelta", "(", "days", "=", "1", ")", "return", "dt" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Holiday.dates
Calculate holidays observed between start date and end date Parameters ---------- start_date : starting date, datetime-like, optional end_date : ending date, datetime-like, optional return_name : bool, optional, default=False If True, return a series that has dates a...
pandas/tseries/holiday.py
def dates(self, start_date, end_date, return_name=False): """ Calculate holidays observed between start date and end date Parameters ---------- start_date : starting date, datetime-like, optional end_date : ending date, datetime-like, optional return_name : bool,...
def dates(self, start_date, end_date, return_name=False): """ Calculate holidays observed between start date and end date Parameters ---------- start_date : starting date, datetime-like, optional end_date : ending date, datetime-like, optional return_name : bool,...
[ "Calculate", "holidays", "observed", "between", "start", "date", "and", "end", "date" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L192-L233
[ "def", "dates", "(", "self", ",", "start_date", ",", "end_date", ",", "return_name", "=", "False", ")", ":", "start_date", "=", "Timestamp", "(", "start_date", ")", "end_date", "=", "Timestamp", "(", "end_date", ")", "filter_start_date", "=", "start_date", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Holiday._reference_dates
Get reference dates for the holiday. Return reference dates for the holiday also returning the year prior to the start_date and year following the end_date. This ensures that any offsets to be applied will yield the holidays within the passed in dates.
pandas/tseries/holiday.py
def _reference_dates(self, start_date, end_date): """ Get reference dates for the holiday. Return reference dates for the holiday also returning the year prior to the start_date and year following the end_date. This ensures that any offsets to be applied will yield the holidays...
def _reference_dates(self, start_date, end_date): """ Get reference dates for the holiday. Return reference dates for the holiday also returning the year prior to the start_date and year following the end_date. This ensures that any offsets to be applied will yield the holidays...
[ "Get", "reference", "dates", "for", "the", "holiday", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L235-L261
[ "def", "_reference_dates", "(", "self", ",", "start_date", ",", "end_date", ")", ":", "if", "self", ".", "start_date", "is", "not", "None", ":", "start_date", "=", "self", ".", "start_date", ".", "tz_localize", "(", "start_date", ".", "tz", ")", "if", "s...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Holiday._apply_rule
Apply the given offset/observance to a DatetimeIndex of dates. Parameters ---------- dates : DatetimeIndex Dates to apply the given offset/observance rule Returns ------- Dates with rules applied
pandas/tseries/holiday.py
def _apply_rule(self, dates): """ Apply the given offset/observance to a DatetimeIndex of dates. Parameters ---------- dates : DatetimeIndex Dates to apply the given offset/observance rule Returns ------- Dates with rules applied """ ...
def _apply_rule(self, dates): """ Apply the given offset/observance to a DatetimeIndex of dates. Parameters ---------- dates : DatetimeIndex Dates to apply the given offset/observance rule Returns ------- Dates with rules applied """ ...
[ "Apply", "the", "given", "offset", "/", "observance", "to", "a", "DatetimeIndex", "of", "dates", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L263-L291
[ "def", "_apply_rule", "(", "self", ",", "dates", ")", ":", "if", "self", ".", "observance", "is", "not", "None", ":", "return", "dates", ".", "map", "(", "lambda", "d", ":", "self", ".", "observance", "(", "d", ")", ")", "if", "self", ".", "offset"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
AbstractHolidayCalendar.holidays
Returns a curve with holidays between start_date and end_date Parameters ---------- start : starting date, datetime-like, optional end : ending date, datetime-like, optional return_name : bool, optional If True, return a series that has dates and holiday names. ...
pandas/tseries/holiday.py
def holidays(self, start=None, end=None, return_name=False): """ Returns a curve with holidays between start_date and end_date Parameters ---------- start : starting date, datetime-like, optional end : ending date, datetime-like, optional return_name : bool, opti...
def holidays(self, start=None, end=None, return_name=False): """ Returns a curve with holidays between start_date and end_date Parameters ---------- start : starting date, datetime-like, optional end : ending date, datetime-like, optional return_name : bool, opti...
[ "Returns", "a", "curve", "with", "holidays", "between", "start_date", "and", "end_date" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L362-L412
[ "def", "holidays", "(", "self", ",", "start", "=", "None", ",", "end", "=", "None", ",", "return_name", "=", "False", ")", ":", "if", "self", ".", "rules", "is", "None", ":", "raise", "Exception", "(", "'Holiday Calendar {name} does not have any '", "'rules ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
AbstractHolidayCalendar.merge_class
Merge holiday calendars together. The base calendar will take precedence to other. The merge will be done based on each holiday's name. Parameters ---------- base : AbstractHolidayCalendar instance/subclass or array of Holiday objects other : AbstractHolidayCal...
pandas/tseries/holiday.py
def merge_class(base, other): """ Merge holiday calendars together. The base calendar will take precedence to other. The merge will be done based on each holiday's name. Parameters ---------- base : AbstractHolidayCalendar instance/subclass or array of ...
def merge_class(base, other): """ Merge holiday calendars together. The base calendar will take precedence to other. The merge will be done based on each holiday's name. Parameters ---------- base : AbstractHolidayCalendar instance/subclass or array of ...
[ "Merge", "holiday", "calendars", "together", ".", "The", "base", "calendar", "will", "take", "precedence", "to", "other", ".", "The", "merge", "will", "be", "done", "based", "on", "each", "holiday", "s", "name", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L415-L447
[ "def", "merge_class", "(", "base", ",", "other", ")", ":", "try", ":", "other", "=", "other", ".", "rules", "except", "AttributeError", ":", "pass", "if", "not", "isinstance", "(", "other", ",", "list", ")", ":", "other", "=", "[", "other", "]", "oth...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
AbstractHolidayCalendar.merge
Merge holiday calendars together. The caller's class rules take precedence. The merge will be done based on each holiday's name. Parameters ---------- other : holiday calendar inplace : bool (default=False) If True set rule_table to holidays, else return ar...
pandas/tseries/holiday.py
def merge(self, other, inplace=False): """ Merge holiday calendars together. The caller's class rules take precedence. The merge will be done based on each holiday's name. Parameters ---------- other : holiday calendar inplace : bool (default=False) ...
def merge(self, other, inplace=False): """ Merge holiday calendars together. The caller's class rules take precedence. The merge will be done based on each holiday's name. Parameters ---------- other : holiday calendar inplace : bool (default=False) ...
[ "Merge", "holiday", "calendars", "together", ".", "The", "caller", "s", "class", "rules", "take", "precedence", ".", "The", "merge", "will", "be", "done", "based", "on", "each", "holiday", "s", "name", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L449-L465
[ "def", "merge", "(", "self", ",", "other", ",", "inplace", "=", "False", ")", ":", "holidays", "=", "self", ".", "merge_class", "(", "self", ",", "other", ")", "if", "inplace", ":", "self", ".", "rules", "=", "holidays", "else", ":", "return", "holid...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
register_option
Register an option in the package-wide pandas config object Parameters ---------- key - a fully-qualified key, e.g. "x.y.option - z". defval - the default value of the option doc - a string description of the option validator - a function of a single argument, should raise `Value...
pandas/_config/config.py
def register_option(key, defval, doc='', validator=None, cb=None): """Register an option in the package-wide pandas config object Parameters ---------- key - a fully-qualified key, e.g. "x.y.option - z". defval - the default value of the option doc - a string description of the o...
def register_option(key, defval, doc='', validator=None, cb=None): """Register an option in the package-wide pandas config object Parameters ---------- key - a fully-qualified key, e.g. "x.y.option - z". defval - the default value of the option doc - a string description of the o...
[ "Register", "an", "option", "in", "the", "package", "-", "wide", "pandas", "config", "object" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/config.py#L415-L479
[ "def", "register_option", "(", "key", ",", "defval", ",", "doc", "=", "''", ",", "validator", "=", "None", ",", "cb", "=", "None", ")", ":", "import", "tokenize", "import", "keyword", "key", "=", "key", ".", "lower", "(", ")", "if", "key", "in", "_...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
deprecate_option
Mark option `key` as deprecated, if code attempts to access this option, a warning will be produced, using `msg` if given, or a default message if not. if `rkey` is given, any access to the key will be re-routed to `rkey`. Neither the existence of `key` nor that if `rkey` is checked. If they do not...
pandas/_config/config.py
def deprecate_option(key, msg=None, rkey=None, removal_ver=None): """ Mark option `key` as deprecated, if code attempts to access this option, a warning will be produced, using `msg` if given, or a default message if not. if `rkey` is given, any access to the key will be re-routed to `rkey`. Ne...
def deprecate_option(key, msg=None, rkey=None, removal_ver=None): """ Mark option `key` as deprecated, if code attempts to access this option, a warning will be produced, using `msg` if given, or a default message if not. if `rkey` is given, any access to the key will be re-routed to `rkey`. Ne...
[ "Mark", "option", "key", "as", "deprecated", "if", "code", "attempts", "to", "access", "this", "option", "a", "warning", "will", "be", "produced", "using", "msg", "if", "given", "or", "a", "default", "message", "if", "not", ".", "if", "rkey", "is", "give...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/config.py#L482-L527
[ "def", "deprecate_option", "(", "key", ",", "msg", "=", "None", ",", "rkey", "=", "None", ",", "removal_ver", "=", "None", ")", ":", "key", "=", "key", ".", "lower", "(", ")", "if", "key", "in", "_deprecated_options", ":", "msg", "=", "\"Option '{key}'...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_select_options
returns a list of keys matching `pat` if pat=="all", returns all registered options
pandas/_config/config.py
def _select_options(pat): """returns a list of keys matching `pat` if pat=="all", returns all registered options """ # short-circuit for exact key if pat in _registered_options: return [pat] # else look through all of them keys = sorted(_registered_options.keys()) if pat == 'a...
def _select_options(pat): """returns a list of keys matching `pat` if pat=="all", returns all registered options """ # short-circuit for exact key if pat in _registered_options: return [pat] # else look through all of them keys = sorted(_registered_options.keys()) if pat == 'a...
[ "returns", "a", "list", "of", "keys", "matching", "pat" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/config.py#L533-L548
[ "def", "_select_options", "(", "pat", ")", ":", "# short-circuit for exact key", "if", "pat", "in", "_registered_options", ":", "return", "[", "pat", "]", "# else look through all of them", "keys", "=", "sorted", "(", "_registered_options", ".", "keys", "(", ")", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_translate_key
if key id deprecated and a replacement key defined, will return the replacement key, otherwise returns `key` as - is
pandas/_config/config.py
def _translate_key(key): """ if key id deprecated and a replacement key defined, will return the replacement key, otherwise returns `key` as - is """ d = _get_deprecated_option(key) if d: return d.rkey or key else: return key
def _translate_key(key): """ if key id deprecated and a replacement key defined, will return the replacement key, otherwise returns `key` as - is """ d = _get_deprecated_option(key) if d: return d.rkey or key else: return key
[ "if", "key", "id", "deprecated", "and", "a", "replacement", "key", "defined", "will", "return", "the", "replacement", "key", "otherwise", "returns", "key", "as", "-", "is" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/config.py#L594-L604
[ "def", "_translate_key", "(", "key", ")", ":", "d", "=", "_get_deprecated_option", "(", "key", ")", "if", "d", ":", "return", "d", ".", "rkey", "or", "key", "else", ":", "return", "key" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_build_option_description
Builds a formatted description of a registered option and prints it
pandas/_config/config.py
def _build_option_description(k): """ Builds a formatted description of a registered option and prints it """ o = _get_registered_option(k) d = _get_deprecated_option(k) s = '{k} '.format(k=k) if o.doc: s += '\n'.join(o.doc.strip().split('\n')) else: s += 'No description avail...
def _build_option_description(k): """ Builds a formatted description of a registered option and prints it """ o = _get_registered_option(k) d = _get_deprecated_option(k) s = '{k} '.format(k=k) if o.doc: s += '\n'.join(o.doc.strip().split('\n')) else: s += 'No description avail...
[ "Builds", "a", "formatted", "description", "of", "a", "registered", "option", "and", "prints", "it" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/config.py#L636-L659
[ "def", "_build_option_description", "(", "k", ")", ":", "o", "=", "_get_registered_option", "(", "k", ")", "d", "=", "_get_deprecated_option", "(", "k", ")", "s", "=", "'{k} '", ".", "format", "(", "k", "=", "k", ")", "if", "o", ".", "doc", ":", "s",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
config_prefix
contextmanager for multiple invocations of API with a common prefix supported API functions: (register / get / set )__option Warning: This is not thread - safe, and won't work properly if you import the API functions into your module using the "from x import y" construct. Example: import pandas....
pandas/_config/config.py
def config_prefix(prefix): """contextmanager for multiple invocations of API with a common prefix supported API functions: (register / get / set )__option Warning: This is not thread - safe, and won't work properly if you import the API functions into your module using the "from x import y" construct....
def config_prefix(prefix): """contextmanager for multiple invocations of API with a common prefix supported API functions: (register / get / set )__option Warning: This is not thread - safe, and won't work properly if you import the API functions into your module using the "from x import y" construct....
[ "contextmanager", "for", "multiple", "invocations", "of", "API", "with", "a", "common", "prefix" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/config.py#L696-L741
[ "def", "config_prefix", "(", "prefix", ")", ":", "# Note: reset_option relies on set_option, and on key directly", "# it does not fit in to this monkey-patching scheme", "global", "register_option", ",", "get_option", ",", "set_option", ",", "reset_option", "def", "wrap", "(", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
CSSResolver.parse
Generates (prop, value) pairs from declarations In a future version may generate parsed tokens from tinycss/tinycss2
pandas/io/formats/css.py
def parse(self, declarations_str): """Generates (prop, value) pairs from declarations In a future version may generate parsed tokens from tinycss/tinycss2 """ for decl in declarations_str.split(';'): if not decl.strip(): continue prop, sep, val = ...
def parse(self, declarations_str): """Generates (prop, value) pairs from declarations In a future version may generate parsed tokens from tinycss/tinycss2 """ for decl in declarations_str.split(';'): if not decl.strip(): continue prop, sep, val = ...
[ "Generates", "(", "prop", "value", ")", "pairs", "from", "declarations" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/css.py#L231-L247
[ "def", "parse", "(", "self", ",", "declarations_str", ")", ":", "for", "decl", "in", "declarations_str", ".", "split", "(", "';'", ")", ":", "if", "not", "decl", ".", "strip", "(", ")", ":", "continue", "prop", ",", "sep", ",", "val", "=", "decl", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037