id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
19,400
pandas-dev/pandas
pandas/core/indexes/base.py
Index.to_series
def to_series(self, index=None, name=None): """ Create a Series with both index and values equal to the index keys useful with map for returning an indexer based on an index. Parameters ---------- index : Index, optional index of resulting Series. If None, de...
python
def to_series(self, index=None, name=None): """ Create a Series with both index and values equal to the index keys useful with map for returning an indexer based on an index. Parameters ---------- index : Index, optional index of resulting Series. If None, de...
[ "def", "to_series", "(", "self", ",", "index", "=", "None", ",", "name", "=", "None", ")", ":", "from", "pandas", "import", "Series", "if", "index", "is", "None", ":", "index", "=", "self", ".", "_shallow_copy", "(", ")", "if", "name", "is", "None", ...
Create a Series with both index and values equal to the index keys useful with map for returning an indexer based on an index. Parameters ---------- index : Index, optional index of resulting Series. If None, defaults to original index name : string, optional ...
[ "Create", "a", "Series", "with", "both", "index", "and", "values", "equal", "to", "the", "index", "keys", "useful", "with", "map", "for", "returning", "an", "indexer", "based", "on", "an", "index", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L1123-L1148
19,401
pandas-dev/pandas
pandas/core/indexes/base.py
Index.to_frame
def to_frame(self, index=True, name=None): """ Create a DataFrame with a column containing the Index. .. versionadded:: 0.24.0 Parameters ---------- index : boolean, default True Set the index of the returned DataFrame as the original Index. name : ...
python
def to_frame(self, index=True, name=None): """ Create a DataFrame with a column containing the Index. .. versionadded:: 0.24.0 Parameters ---------- index : boolean, default True Set the index of the returned DataFrame as the original Index. name : ...
[ "def", "to_frame", "(", "self", ",", "index", "=", "True", ",", "name", "=", "None", ")", ":", "from", "pandas", "import", "DataFrame", "if", "name", "is", "None", ":", "name", "=", "self", ".", "name", "or", "0", "result", "=", "DataFrame", "(", "...
Create a DataFrame with a column containing the Index. .. versionadded:: 0.24.0 Parameters ---------- index : boolean, default True Set the index of the returned DataFrame as the original Index. name : object, default None The passed name should substit...
[ "Create", "a", "DataFrame", "with", "a", "column", "containing", "the", "Index", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L1150-L1209
19,402
pandas-dev/pandas
pandas/core/indexes/base.py
Index._validate_names
def _validate_names(self, name=None, names=None, deep=False): """ Handles the quirks of having a singular 'name' parameter for general Index and plural 'names' parameter for MultiIndex. """ from copy import deepcopy if names is not None and name is not None: r...
python
def _validate_names(self, name=None, names=None, deep=False): """ Handles the quirks of having a singular 'name' parameter for general Index and plural 'names' parameter for MultiIndex. """ from copy import deepcopy if names is not None and name is not None: r...
[ "def", "_validate_names", "(", "self", ",", "name", "=", "None", ",", "names", "=", "None", ",", "deep", "=", "False", ")", ":", "from", "copy", "import", "deepcopy", "if", "names", "is", "not", "None", "and", "name", "is", "not", "None", ":", "raise...
Handles the quirks of having a singular 'name' parameter for general Index and plural 'names' parameter for MultiIndex.
[ "Handles", "the", "quirks", "of", "having", "a", "singular", "name", "parameter", "for", "general", "Index", "and", "plural", "names", "parameter", "for", "MultiIndex", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L1214-L1231
19,403
pandas-dev/pandas
pandas/core/indexes/base.py
Index.set_names
def set_names(self, names, level=None, inplace=False): """ Set Index or MultiIndex name. Able to set new names partially and by level. Parameters ---------- names : label or list of label Name(s) to set. level : int, label or list of int or label, op...
python
def set_names(self, names, level=None, inplace=False): """ Set Index or MultiIndex name. Able to set new names partially and by level. Parameters ---------- names : label or list of label Name(s) to set. level : int, label or list of int or label, op...
[ "def", "set_names", "(", "self", ",", "names", ",", "level", "=", "None", ",", "inplace", "=", "False", ")", ":", "if", "level", "is", "not", "None", "and", "not", "isinstance", "(", "self", ",", "ABCMultiIndex", ")", ":", "raise", "ValueError", "(", ...
Set Index or MultiIndex name. Able to set new names partially and by level. Parameters ---------- names : label or list of label Name(s) to set. level : int, label or list of int or label, optional If the index is a MultiIndex, level(s) to set (None for ...
[ "Set", "Index", "or", "MultiIndex", "name", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L1268-L1340
19,404
pandas-dev/pandas
pandas/core/indexes/base.py
Index.rename
def rename(self, name, inplace=False): """ Alter Index or MultiIndex name. Able to set new names without level. Defaults to returning new index. Length of names must match number of levels in MultiIndex. Parameters ---------- name : label or list of labels ...
python
def rename(self, name, inplace=False): """ Alter Index or MultiIndex name. Able to set new names without level. Defaults to returning new index. Length of names must match number of levels in MultiIndex. Parameters ---------- name : label or list of labels ...
[ "def", "rename", "(", "self", ",", "name", ",", "inplace", "=", "False", ")", ":", "return", "self", ".", "set_names", "(", "[", "name", "]", ",", "inplace", "=", "inplace", ")" ]
Alter Index or MultiIndex name. Able to set new names without level. Defaults to returning new index. Length of names must match number of levels in MultiIndex. Parameters ---------- name : label or list of labels Name(s) to set. inplace : boolean, default F...
[ "Alter", "Index", "or", "MultiIndex", "name", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L1342-L1387
19,405
pandas-dev/pandas
pandas/core/indexes/base.py
Index._validate_index_level
def _validate_index_level(self, level): """ Validate index level. For single-level Index getting level number is a no-op, but some verification must be done like in MultiIndex. """ if isinstance(level, int): if level < 0 and level != -1: rais...
python
def _validate_index_level(self, level): """ Validate index level. For single-level Index getting level number is a no-op, but some verification must be done like in MultiIndex. """ if isinstance(level, int): if level < 0 and level != -1: rais...
[ "def", "_validate_index_level", "(", "self", ",", "level", ")", ":", "if", "isinstance", "(", "level", ",", "int", ")", ":", "if", "level", "<", "0", "and", "level", "!=", "-", "1", ":", "raise", "IndexError", "(", "\"Too many levels: Index has only 1 level,...
Validate index level. For single-level Index getting level number is a no-op, but some verification must be done like in MultiIndex.
[ "Validate", "index", "level", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L1402-L1420
19,406
pandas-dev/pandas
pandas/core/indexes/base.py
Index.sortlevel
def sortlevel(self, level=None, ascending=True, sort_remaining=None): """ For internal compatibility with with the Index API. Sort the Index. This is for compat with MultiIndex Parameters ---------- ascending : boolean, default True False to sort in descendi...
python
def sortlevel(self, level=None, ascending=True, sort_remaining=None): """ For internal compatibility with with the Index API. Sort the Index. This is for compat with MultiIndex Parameters ---------- ascending : boolean, default True False to sort in descendi...
[ "def", "sortlevel", "(", "self", ",", "level", "=", "None", ",", "ascending", "=", "True", ",", "sort_remaining", "=", "None", ")", ":", "return", "self", ".", "sort_values", "(", "return_indexer", "=", "True", ",", "ascending", "=", "ascending", ")" ]
For internal compatibility with with the Index API. Sort the Index. This is for compat with MultiIndex Parameters ---------- ascending : boolean, default True False to sort in descending order level, sort_remaining are compat parameters Returns ---...
[ "For", "internal", "compatibility", "with", "with", "the", "Index", "API", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L1426-L1443
19,407
pandas-dev/pandas
pandas/core/indexes/base.py
Index._isnan
def _isnan(self): """ Return if each value is NaN. """ if self._can_hold_na: return isna(self) else: # shouldn't reach to this condition by checking hasnans beforehand values = np.empty(len(self), dtype=np.bool_) values.fill(False) ...
python
def _isnan(self): """ Return if each value is NaN. """ if self._can_hold_na: return isna(self) else: # shouldn't reach to this condition by checking hasnans beforehand values = np.empty(len(self), dtype=np.bool_) values.fill(False) ...
[ "def", "_isnan", "(", "self", ")", ":", "if", "self", ".", "_can_hold_na", ":", "return", "isna", "(", "self", ")", "else", ":", "# shouldn't reach to this condition by checking hasnans beforehand", "values", "=", "np", ".", "empty", "(", "len", "(", "self", "...
Return if each value is NaN.
[ "Return", "if", "each", "value", "is", "NaN", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L1782-L1792
19,408
pandas-dev/pandas
pandas/core/indexes/base.py
Index.get_duplicates
def get_duplicates(self): """ Extract duplicated index elements. .. deprecated:: 0.23.0 Use idx[idx.duplicated()].unique() instead Returns a sorted list of index elements which appear more than once in the index. Returns ------- array-like ...
python
def get_duplicates(self): """ Extract duplicated index elements. .. deprecated:: 0.23.0 Use idx[idx.duplicated()].unique() instead Returns a sorted list of index elements which appear more than once in the index. Returns ------- array-like ...
[ "def", "get_duplicates", "(", "self", ")", ":", "warnings", ".", "warn", "(", "\"'get_duplicates' is deprecated and will be removed in \"", "\"a future release. You can use \"", "\"idx[idx.duplicated()].unique() instead\"", ",", "FutureWarning", ",", "stacklevel", "=", "2", ")"...
Extract duplicated index elements. .. deprecated:: 0.23.0 Use idx[idx.duplicated()].unique() instead Returns a sorted list of index elements which appear more than once in the index. Returns ------- array-like List of duplicated indexes. ...
[ "Extract", "duplicated", "index", "elements", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L2105-L2162
19,409
pandas-dev/pandas
pandas/core/indexes/base.py
Index._get_unique_index
def _get_unique_index(self, dropna=False): """ Returns an index containing unique values. Parameters ---------- dropna : bool If True, NaN values are dropped. Returns ------- uniques : index """ if self.is_unique and not dropn...
python
def _get_unique_index(self, dropna=False): """ Returns an index containing unique values. Parameters ---------- dropna : bool If True, NaN values are dropped. Returns ------- uniques : index """ if self.is_unique and not dropn...
[ "def", "_get_unique_index", "(", "self", ",", "dropna", "=", "False", ")", ":", "if", "self", ".", "is_unique", "and", "not", "dropna", ":", "return", "self", "values", "=", "self", ".", "values", "if", "not", "self", ".", "is_unique", ":", "values", "...
Returns an index containing unique values. Parameters ---------- dropna : bool If True, NaN values are dropped. Returns ------- uniques : index
[ "Returns", "an", "index", "containing", "unique", "values", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L2164-L2192
19,410
pandas-dev/pandas
pandas/core/indexes/base.py
Index._get_reconciled_name_object
def _get_reconciled_name_object(self, other): """ If the result of a set operation will be self, return self, unless the name changes, in which case make a shallow copy of self. """ name = get_op_result_name(self, other) if self.name != name: return se...
python
def _get_reconciled_name_object(self, other): """ If the result of a set operation will be self, return self, unless the name changes, in which case make a shallow copy of self. """ name = get_op_result_name(self, other) if self.name != name: return se...
[ "def", "_get_reconciled_name_object", "(", "self", ",", "other", ")", ":", "name", "=", "get_op_result_name", "(", "self", ",", "other", ")", "if", "self", ".", "name", "!=", "name", ":", "return", "self", ".", "_shallow_copy", "(", "name", "=", "name", ...
If the result of a set operation will be self, return self, unless the name changes, in which case make a shallow copy of self.
[ "If", "the", "result", "of", "a", "set", "operation", "will", "be", "self", "return", "self", "unless", "the", "name", "changes", "in", "which", "case", "make", "a", "shallow", "copy", "of", "self", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L2234-L2243
19,411
pandas-dev/pandas
pandas/core/indexes/base.py
Index.union
def union(self, other, sort=None): """ Form the union of two Index objects. Parameters ---------- other : Index or array-like sort : bool or None, default None Whether to sort the resulting Index. * None : Sort the result, except when ...
python
def union(self, other, sort=None): """ Form the union of two Index objects. Parameters ---------- other : Index or array-like sort : bool or None, default None Whether to sort the resulting Index. * None : Sort the result, except when ...
[ "def", "union", "(", "self", ",", "other", ",", "sort", "=", "None", ")", ":", "self", ".", "_validate_sort_keyword", "(", "sort", ")", "self", ".", "_assert_can_do_setop", "(", "other", ")", "other", "=", "ensure_index", "(", "other", ")", "if", "len", ...
Form the union of two Index objects. Parameters ---------- other : Index or array-like sort : bool or None, default None Whether to sort the resulting Index. * None : Sort the result, except when 1. `self` and `other` are equal. 2. `...
[ "Form", "the", "union", "of", "two", "Index", "objects", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L2250-L2348
19,412
pandas-dev/pandas
pandas/core/indexes/base.py
Index.difference
def difference(self, other, sort=None): """ Return a new Index with elements from the index that are not in `other`. This is the set difference of two Index objects. Parameters ---------- other : Index or array-like sort : False or None, default None ...
python
def difference(self, other, sort=None): """ Return a new Index with elements from the index that are not in `other`. This is the set difference of two Index objects. Parameters ---------- other : Index or array-like sort : False or None, default None ...
[ "def", "difference", "(", "self", ",", "other", ",", "sort", "=", "None", ")", ":", "self", ".", "_validate_sort_keyword", "(", "sort", ")", "self", ".", "_assert_can_do_setop", "(", "other", ")", "if", "self", ".", "equals", "(", "other", ")", ":", "#...
Return a new Index with elements from the index that are not in `other`. This is the set difference of two Index objects. Parameters ---------- other : Index or array-like sort : False or None, default None Whether to sort the resulting index. By default, th...
[ "Return", "a", "new", "Index", "with", "elements", "from", "the", "index", "that", "are", "not", "in", "other", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L2441-L2504
19,413
pandas-dev/pandas
pandas/core/indexes/base.py
Index.symmetric_difference
def symmetric_difference(self, other, result_name=None, sort=None): """ Compute the symmetric difference of two Index objects. Parameters ---------- other : Index or array-like result_name : str sort : False or None, default None Whether to sort the r...
python
def symmetric_difference(self, other, result_name=None, sort=None): """ Compute the symmetric difference of two Index objects. Parameters ---------- other : Index or array-like result_name : str sort : False or None, default None Whether to sort the r...
[ "def", "symmetric_difference", "(", "self", ",", "other", ",", "result_name", "=", "None", ",", "sort", "=", "None", ")", ":", "self", ".", "_validate_sort_keyword", "(", "sort", ")", "self", ".", "_assert_can_do_setop", "(", "other", ")", "other", ",", "r...
Compute the symmetric difference of two Index objects. Parameters ---------- other : Index or array-like result_name : str sort : False or None, default None Whether to sort the resulting index. By default, the values are attempted to be sorted, but any T...
[ "Compute", "the", "symmetric", "difference", "of", "two", "Index", "objects", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L2506-L2584
19,414
pandas-dev/pandas
pandas/core/indexes/base.py
Index._invalid_indexer
def _invalid_indexer(self, form, key): """ Consistent invalid indexer message. """ raise TypeError("cannot do {form} indexing on {klass} with these " "indexers [{key}] of {kind}".format( form=form, klass=type(self), key=key, ...
python
def _invalid_indexer(self, form, key): """ Consistent invalid indexer message. """ raise TypeError("cannot do {form} indexing on {klass} with these " "indexers [{key}] of {kind}".format( form=form, klass=type(self), key=key, ...
[ "def", "_invalid_indexer", "(", "self", ",", "form", ",", "key", ")", ":", "raise", "TypeError", "(", "\"cannot do {form} indexing on {klass} with these \"", "\"indexers [{key}] of {kind}\"", ".", "format", "(", "form", "=", "form", ",", "klass", "=", "type", "(", ...
Consistent invalid indexer message.
[ "Consistent", "invalid", "indexer", "message", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L3057-L3064
19,415
pandas-dev/pandas
pandas/core/indexes/base.py
Index._try_convert_to_int_index
def _try_convert_to_int_index(cls, data, copy, name, dtype): """ Attempt to convert an array of data into an integer index. Parameters ---------- data : The data to convert. copy : Whether to copy the data or not. name : The name of the index returned. R...
python
def _try_convert_to_int_index(cls, data, copy, name, dtype): """ Attempt to convert an array of data into an integer index. Parameters ---------- data : The data to convert. copy : Whether to copy the data or not. name : The name of the index returned. R...
[ "def", "_try_convert_to_int_index", "(", "cls", ",", "data", ",", "copy", ",", "name", ",", "dtype", ")", ":", "from", ".", "numeric", "import", "Int64Index", ",", "UInt64Index", "if", "not", "is_unsigned_integer_dtype", "(", "dtype", ")", ":", "# skip int64 c...
Attempt to convert an array of data into an integer index. Parameters ---------- data : The data to convert. copy : Whether to copy the data or not. name : The name of the index returned. Returns ------- int_index : data converted to either an Int64Index...
[ "Attempt", "to", "convert", "an", "array", "of", "data", "into", "an", "integer", "index", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L3746-L3786
19,416
pandas-dev/pandas
pandas/core/indexes/base.py
Index._coerce_to_ndarray
def _coerce_to_ndarray(cls, data): """ Coerces data to ndarray. Converts other iterables to list first and then to array. Does not touch ndarrays. Raises ------ TypeError When the data passed in is a scalar. """ if not isinstance(dat...
python
def _coerce_to_ndarray(cls, data): """ Coerces data to ndarray. Converts other iterables to list first and then to array. Does not touch ndarrays. Raises ------ TypeError When the data passed in is a scalar. """ if not isinstance(dat...
[ "def", "_coerce_to_ndarray", "(", "cls", ",", "data", ")", ":", "if", "not", "isinstance", "(", "data", ",", "(", "np", ".", "ndarray", ",", "Index", ")", ")", ":", "if", "data", "is", "None", "or", "is_scalar", "(", "data", ")", ":", "cls", ".", ...
Coerces data to ndarray. Converts other iterables to list first and then to array. Does not touch ndarrays. Raises ------ TypeError When the data passed in is a scalar.
[ "Coerces", "data", "to", "ndarray", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L3800-L3821
19,417
pandas-dev/pandas
pandas/core/indexes/base.py
Index._coerce_scalar_to_index
def _coerce_scalar_to_index(self, item): """ We need to coerce a scalar to a compat for our index type. Parameters ---------- item : scalar item to coerce """ dtype = self.dtype if self._is_numeric_dtype and isna(item): # We can't coerce to t...
python
def _coerce_scalar_to_index(self, item): """ We need to coerce a scalar to a compat for our index type. Parameters ---------- item : scalar item to coerce """ dtype = self.dtype if self._is_numeric_dtype and isna(item): # We can't coerce to t...
[ "def", "_coerce_scalar_to_index", "(", "self", ",", "item", ")", ":", "dtype", "=", "self", ".", "dtype", "if", "self", ".", "_is_numeric_dtype", "and", "isna", "(", "item", ")", ":", "# We can't coerce to the numeric dtype of \"self\" (unless", "# it's float) if ther...
We need to coerce a scalar to a compat for our index type. Parameters ---------- item : scalar item to coerce
[ "We", "need", "to", "coerce", "a", "scalar", "to", "a", "compat", "for", "our", "index", "type", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L3823-L3838
19,418
pandas-dev/pandas
pandas/core/indexes/base.py
Index._assert_can_do_op
def _assert_can_do_op(self, value): """ Check value is valid for scalar op. """ if not is_scalar(value): msg = "'value' must be a scalar, passed: {0}" raise TypeError(msg.format(type(value).__name__))
python
def _assert_can_do_op(self, value): """ Check value is valid for scalar op. """ if not is_scalar(value): msg = "'value' must be a scalar, passed: {0}" raise TypeError(msg.format(type(value).__name__))
[ "def", "_assert_can_do_op", "(", "self", ",", "value", ")", ":", "if", "not", "is_scalar", "(", "value", ")", ":", "msg", "=", "\"'value' must be a scalar, passed: {0}\"", "raise", "TypeError", "(", "msg", ".", "format", "(", "type", "(", "value", ")", ".", ...
Check value is valid for scalar op.
[ "Check", "value", "is", "valid", "for", "scalar", "op", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L3852-L3858
19,419
pandas-dev/pandas
pandas/core/indexes/base.py
Index.append
def append(self, other): """ Append a collection of Index options together. Parameters ---------- other : Index or list/tuple of indices Returns ------- appended : Index """ to_concat = [self] if isinstance(other, (list, tuple))...
python
def append(self, other): """ Append a collection of Index options together. Parameters ---------- other : Index or list/tuple of indices Returns ------- appended : Index """ to_concat = [self] if isinstance(other, (list, tuple))...
[ "def", "append", "(", "self", ",", "other", ")", ":", "to_concat", "=", "[", "self", "]", "if", "isinstance", "(", "other", ",", "(", "list", ",", "tuple", ")", ")", ":", "to_concat", "=", "to_concat", "+", "list", "(", "other", ")", "else", ":", ...
Append a collection of Index options together. Parameters ---------- other : Index or list/tuple of indices Returns ------- appended : Index
[ "Append", "a", "collection", "of", "Index", "options", "together", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L3981-L4008
19,420
pandas-dev/pandas
pandas/core/indexes/base.py
Index.putmask
def putmask(self, mask, value): """ Return a new Index of the values set with the mask. See Also -------- numpy.ndarray.putmask """ values = self.values.copy() try: np.putmask(values, mask, self._convert_for_op(value)) return self....
python
def putmask(self, mask, value): """ Return a new Index of the values set with the mask. See Also -------- numpy.ndarray.putmask """ values = self.values.copy() try: np.putmask(values, mask, self._convert_for_op(value)) return self....
[ "def", "putmask", "(", "self", ",", "mask", ",", "value", ")", ":", "values", "=", "self", ".", "values", ".", "copy", "(", ")", "try", ":", "np", ".", "putmask", "(", "values", ",", "mask", ",", "self", ".", "_convert_for_op", "(", "value", ")", ...
Return a new Index of the values set with the mask. See Also -------- numpy.ndarray.putmask
[ "Return", "a", "new", "Index", "of", "the", "values", "set", "with", "the", "mask", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4025-L4042
19,421
pandas-dev/pandas
pandas/core/indexes/base.py
Index.equals
def equals(self, other): """ Determine if two Index objects contain the same elements. """ if self.is_(other): return True if not isinstance(other, Index): return False if is_object_dtype(self) and not is_object_dtype(other): # if oth...
python
def equals(self, other): """ Determine if two Index objects contain the same elements. """ if self.is_(other): return True if not isinstance(other, Index): return False if is_object_dtype(self) and not is_object_dtype(other): # if oth...
[ "def", "equals", "(", "self", ",", "other", ")", ":", "if", "self", ".", "is_", "(", "other", ")", ":", "return", "True", "if", "not", "isinstance", "(", "other", ",", "Index", ")", ":", "return", "False", "if", "is_object_dtype", "(", "self", ")", ...
Determine if two Index objects contain the same elements.
[ "Determine", "if", "two", "Index", "objects", "contain", "the", "same", "elements", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4044-L4062
19,422
pandas-dev/pandas
pandas/core/indexes/base.py
Index.identical
def identical(self, other): """ Similar to equals, but check that other comparable attributes are also equal. """ return (self.equals(other) and all((getattr(self, c, None) == getattr(other, c, None) for c in self._comparables)) and ...
python
def identical(self, other): """ Similar to equals, but check that other comparable attributes are also equal. """ return (self.equals(other) and all((getattr(self, c, None) == getattr(other, c, None) for c in self._comparables)) and ...
[ "def", "identical", "(", "self", ",", "other", ")", ":", "return", "(", "self", ".", "equals", "(", "other", ")", "and", "all", "(", "(", "getattr", "(", "self", ",", "c", ",", "None", ")", "==", "getattr", "(", "other", ",", "c", ",", "None", ...
Similar to equals, but check that other comparable attributes are also equal.
[ "Similar", "to", "equals", "but", "check", "that", "other", "comparable", "attributes", "are", "also", "equal", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4064-L4072
19,423
pandas-dev/pandas
pandas/core/indexes/base.py
Index.asof
def asof(self, label): """ Return the label from the index, or, if not present, the previous one. Assuming that the index is sorted, return the passed index label if it is in the index, or return the previous index label if the passed one is not in the index. Parameters...
python
def asof(self, label): """ Return the label from the index, or, if not present, the previous one. Assuming that the index is sorted, return the passed index label if it is in the index, or return the previous index label if the passed one is not in the index. Parameters...
[ "def", "asof", "(", "self", ",", "label", ")", ":", "try", ":", "loc", "=", "self", ".", "get_loc", "(", "label", ",", "method", "=", "'pad'", ")", "except", "KeyError", ":", "return", "self", ".", "_na_value", "else", ":", "if", "isinstance", "(", ...
Return the label from the index, or, if not present, the previous one. Assuming that the index is sorted, return the passed index label if it is in the index, or return the previous index label if the passed one is not in the index. Parameters ---------- label : object ...
[ "Return", "the", "label", "from", "the", "index", "or", "if", "not", "present", "the", "previous", "one", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4074-L4137
19,424
pandas-dev/pandas
pandas/core/indexes/base.py
Index.sort_values
def sort_values(self, return_indexer=False, ascending=True): """ Return a sorted copy of the index. Return a sorted copy of the index, and optionally return the indices that sorted the index itself. Parameters ---------- return_indexer : bool, default False ...
python
def sort_values(self, return_indexer=False, ascending=True): """ Return a sorted copy of the index. Return a sorted copy of the index, and optionally return the indices that sorted the index itself. Parameters ---------- return_indexer : bool, default False ...
[ "def", "sort_values", "(", "self", ",", "return_indexer", "=", "False", ",", "ascending", "=", "True", ")", ":", "_as", "=", "self", ".", "argsort", "(", ")", "if", "not", "ascending", ":", "_as", "=", "_as", "[", ":", ":", "-", "1", "]", "sorted_i...
Return a sorted copy of the index. Return a sorted copy of the index, and optionally return the indices that sorted the index itself. Parameters ---------- return_indexer : bool, default False Should the indices that would sort the index be returned. ascendi...
[ "Return", "a", "sorted", "copy", "of", "the", "index", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4178-L4230
19,425
pandas-dev/pandas
pandas/core/indexes/base.py
Index.argsort
def argsort(self, *args, **kwargs): """ Return the integer indices that would sort the index. Parameters ---------- *args Passed to `numpy.ndarray.argsort`. **kwargs Passed to `numpy.ndarray.argsort`. Returns ------- numpy...
python
def argsort(self, *args, **kwargs): """ Return the integer indices that would sort the index. Parameters ---------- *args Passed to `numpy.ndarray.argsort`. **kwargs Passed to `numpy.ndarray.argsort`. Returns ------- numpy...
[ "def", "argsort", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "self", ".", "asi8", "if", "result", "is", "None", ":", "result", "=", "np", ".", "array", "(", "self", ")", "return", "result", ".", "argsort", "(...
Return the integer indices that would sort the index. Parameters ---------- *args Passed to `numpy.ndarray.argsort`. **kwargs Passed to `numpy.ndarray.argsort`. Returns ------- numpy.ndarray Integer indices that would sort the...
[ "Return", "the", "integer", "indices", "that", "would", "sort", "the", "index", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4295-L4333
19,426
pandas-dev/pandas
pandas/core/indexes/base.py
Index.get_value
def get_value(self, series, key): """ Fast lookup of value from 1-dimensional ndarray. Only use this if you know what you're doing. """ # if we have something that is Index-like, then # use this, e.g. DatetimeIndex # Things like `Series._get_value` (via .at) pass...
python
def get_value(self, series, key): """ Fast lookup of value from 1-dimensional ndarray. Only use this if you know what you're doing. """ # if we have something that is Index-like, then # use this, e.g. DatetimeIndex # Things like `Series._get_value` (via .at) pass...
[ "def", "get_value", "(", "self", ",", "series", ",", "key", ")", ":", "# if we have something that is Index-like, then", "# use this, e.g. DatetimeIndex", "# Things like `Series._get_value` (via .at) pass the EA directly here.", "s", "=", "getattr", "(", "series", ",", "'_value...
Fast lookup of value from 1-dimensional ndarray. Only use this if you know what you're doing.
[ "Fast", "lookup", "of", "value", "from", "1", "-", "dimensional", "ndarray", ".", "Only", "use", "this", "if", "you", "know", "what", "you", "re", "doing", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4335-L4389
19,427
pandas-dev/pandas
pandas/core/indexes/base.py
Index.set_value
def set_value(self, arr, key, value): """ Fast lookup of value from 1-dimensional ndarray. Notes ----- Only use this if you know what you're doing. """ self._engine.set_value(com.values_from_object(arr), com.values_from_object(key),...
python
def set_value(self, arr, key, value): """ Fast lookup of value from 1-dimensional ndarray. Notes ----- Only use this if you know what you're doing. """ self._engine.set_value(com.values_from_object(arr), com.values_from_object(key),...
[ "def", "set_value", "(", "self", ",", "arr", ",", "key", ",", "value", ")", ":", "self", ".", "_engine", ".", "set_value", "(", "com", ".", "values_from_object", "(", "arr", ")", ",", "com", ".", "values_from_object", "(", "key", ")", ",", "value", "...
Fast lookup of value from 1-dimensional ndarray. Notes ----- Only use this if you know what you're doing.
[ "Fast", "lookup", "of", "value", "from", "1", "-", "dimensional", "ndarray", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4391-L4400
19,428
pandas-dev/pandas
pandas/core/indexes/base.py
Index.get_indexer_for
def get_indexer_for(self, target, **kwargs): """ Guaranteed return of an indexer even when non-unique. This dispatches to get_indexer or get_indexer_nonunique as appropriate. """ if self.is_unique: return self.get_indexer(target, **kwargs) indexer, _ ...
python
def get_indexer_for(self, target, **kwargs): """ Guaranteed return of an indexer even when non-unique. This dispatches to get_indexer or get_indexer_nonunique as appropriate. """ if self.is_unique: return self.get_indexer(target, **kwargs) indexer, _ ...
[ "def", "get_indexer_for", "(", "self", ",", "target", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "is_unique", ":", "return", "self", ".", "get_indexer", "(", "target", ",", "*", "*", "kwargs", ")", "indexer", ",", "_", "=", "self", ".", ...
Guaranteed return of an indexer even when non-unique. This dispatches to get_indexer or get_indexer_nonunique as appropriate.
[ "Guaranteed", "return", "of", "an", "indexer", "even", "when", "non", "-", "unique", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4440-L4450
19,429
pandas-dev/pandas
pandas/core/indexes/base.py
Index.groupby
def groupby(self, values): """ Group the index labels by a given array of values. Parameters ---------- values : array Values used to determine the groups. Returns ------- groups : dict {group name -> group labels} """ ...
python
def groupby(self, values): """ Group the index labels by a given array of values. Parameters ---------- values : array Values used to determine the groups. Returns ------- groups : dict {group name -> group labels} """ ...
[ "def", "groupby", "(", "self", ",", "values", ")", ":", "# TODO: if we are a MultiIndex, we can do better", "# that converting to tuples", "if", "isinstance", "(", "values", ",", "ABCMultiIndex", ")", ":", "values", "=", "values", ".", "values", "values", "=", "ensu...
Group the index labels by a given array of values. Parameters ---------- values : array Values used to determine the groups. Returns ------- groups : dict {group name -> group labels}
[ "Group", "the", "index", "labels", "by", "a", "given", "array", "of", "values", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4462-L4487
19,430
pandas-dev/pandas
pandas/core/indexes/base.py
Index.isin
def isin(self, values, level=None): """ Return a boolean array where the index values are in `values`. Compute boolean array of whether each index value is found in the passed set of values. The length of the returned boolean array matches the length of the index. Param...
python
def isin(self, values, level=None): """ Return a boolean array where the index values are in `values`. Compute boolean array of whether each index value is found in the passed set of values. The length of the returned boolean array matches the length of the index. Param...
[ "def", "isin", "(", "self", ",", "values", ",", "level", "=", "None", ")", ":", "if", "level", "is", "not", "None", ":", "self", ".", "_validate_index_level", "(", "level", ")", "return", "algos", ".", "isin", "(", "self", ",", "values", ")" ]
Return a boolean array where the index values are in `values`. Compute boolean array of whether each index value is found in the passed set of values. The length of the returned boolean array matches the length of the index. Parameters ---------- values : set or list-li...
[ "Return", "a", "boolean", "array", "where", "the", "index", "values", "are", "in", "values", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4532-L4618
19,431
pandas-dev/pandas
pandas/core/indexes/base.py
Index.slice_indexer
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...
python
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", ")", ":", "start_slice", ",", "end_slice", "=", "self", ".", "slice_locs", "(", "start", ",", "end", ",", "...
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...
[ "For", "an", "ordered", "or", "unique", "index", "compute", "the", "slice", "indexer", "for", "input", "labels", "and", "step", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4625-L4673
19,432
pandas-dev/pandas
pandas/core/indexes/base.py
Index._maybe_cast_indexer
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: ...
python
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", "is_float", "(", "key", ")", "and", "not", "self", ".", "is_floating", "(", ")", ":", "try", ":", "ckey", "=", "int", "(", "key", ")", "if", "ckey", "==", "key", ":", "key", "...
If we have a float key and are not a floating index, then try to cast to an int if equivalent.
[ "If", "we", "have", "a", "float", "key", "and", "are", "not", "a", "floating", "index", "then", "try", "to", "cast", "to", "an", "int", "if", "equivalent", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4675-L4688
19,433
pandas-dev/pandas
pandas/core/indexes/base.py
Index._validate_indexer
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): ...
python
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", ")", ":", "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.
[ "If", "we", "are", "positional", "indexer", "validate", "that", "we", "have", "appropriate", "typed", "bounds", "must", "be", "an", "integer", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4690-L4703
19,434
pandas-dev/pandas
pandas/core/indexes/base.py
Index.get_slice_bound
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'}...
python
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", ")", ":", "assert", "kind", "in", "[", "'ix'", ",", "'loc'", ",", "'getitem'", ",", "None", "]", "if", "side", "not", "in", "(", "'left'", ",", "'right'", ")", ":", "rai...
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'}
[ "Calculate", "slice", "bound", "that", "corresponds", "to", "given", "label", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4766-L4822
19,435
pandas-dev/pandas
pandas/core/indexes/base.py
Index.slice_locs
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...
python
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", ")", ":", "inc", "=", "(", "step", "is", "None", "or", "step", ">=", "0", ")", "if", "not", "inc", ":", ...
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...
[ "Compute", "slice", "locations", "for", "input", "labels", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4824-L4913
19,436
pandas-dev/pandas
pandas/core/indexes/base.py
Index.insert
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 """ ...
python
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", ")", ":", "_self", "=", "np", ".", "asarray", "(", "self", ")", "item", "=", "self", ".", "_coerce_scalar_to_index", "(", "item", ")", ".", "_ndarray_values", "idx", "=", "np", ".", "concatenate", ...
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", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4925-L4943
19,437
pandas-dev/pandas
pandas/core/indexes/base.py
Index.drop
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...
python
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'", ")", ":", "arr_dtype", "=", "'object'", "if", "self", ".", "dtype", "==", "'object'", "else", "None", "labels", "=", "com", ".", "index_labels_to_array", "(", "labels", ",", "dtype...
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 ...
[ "Make", "new", "Index", "with", "passed", "list", "of", "labels", "deleted", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4945-L4973
19,438
pandas-dev/pandas
pandas/core/indexes/base.py
Index._add_comparison_methods
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....
python
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", ")", ":", "cls", ".", "__eq__", "=", "_make_comparison_op", "(", "operator", ".", "eq", ",", "cls", ")", "cls", ".", "__ne__", "=", "_make_comparison_op", "(", "operator", ".", "ne", ",", "cls", ")", "cls", "...
Add in comparison methods.
[ "Add", "in", "comparison", "methods", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L5004-L5013
19,439
pandas-dev/pandas
pandas/core/indexes/base.py
Index._validate_for_numeric_unaryop
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}" ....
python
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", ")", ":", "if", "not", "self", ".", "_is_numeric_dtype", ":", "raise", "TypeError", "(", "\"cannot evaluate a numeric op \"", "\"{opstr} for type: {typ}\"", ".", "format", "(", "opstr", "=...
Validate if we can perform a numeric unary operation.
[ "Validate", "if", "we", "can", "perform", "a", "numeric", "unary", "operation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L5053-L5060
19,440
pandas-dev/pandas
pandas/core/indexes/base.py
Index._validate_for_numeric_binop
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__) ...
python
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", ")", ":", "opstr", "=", "'__{opname}__'", ".", "format", "(", "opname", "=", "op", ".", "__name__", ")", "# if we are an inheritor of numeric,", "# but not actually numeric (e.g. DatetimeIndex/P...
Return valid other; evaluate or raise TypeError if we are not of the appropriate type. Notes ----- This is an internal method called by ops.
[ "Return", "valid", "other", ";", "evaluate", "or", "raise", "TypeError", "if", "we", "are", "not", "of", "the", "appropriate", "type", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L5062-L5105
19,441
pandas-dev/pandas
pandas/core/indexes/base.py
Index._add_numeric_methods_binary
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...
python
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", ")", ":", "cls", ".", "__add__", "=", "_make_arithmetic_op", "(", "operator", ".", "add", ",", "cls", ")", "cls", ".", "__radd__", "=", "_make_arithmetic_op", "(", "ops", ".", "radd", ",", "cls", ")", "cls"...
Add in numeric methods.
[ "Add", "in", "numeric", "methods", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L5108-L5128
19,442
pandas-dev/pandas
pandas/core/indexes/base.py
Index._add_numeric_methods_unary
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() ...
python
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", ")", ":", "def", "_make_evaluate_unary", "(", "op", ",", "opstr", ")", ":", "def", "_evaluate_numeric_unary", "(", "self", ")", ":", "self", ".", "_validate_for_numeric_unaryop", "(", "op", ",", "opstr", ")", "a...
Add in numeric unary methods.
[ "Add", "in", "numeric", "unary", "methods", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L5131-L5150
19,443
pandas-dev/pandas
pandas/core/indexes/base.py
Index._add_logical_methods
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...
python
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", ")", ":", "_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....
Add in logical methods.
[ "Add", "in", "logical", "methods", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L5158-L5261
19,444
pandas-dev/pandas
pandas/core/groupby/grouper.py
Grouper._set_grouper
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...
python
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", ")", ":", "if", "self", ".", "key", "is", "not", "None", "and", "self", ".", "level", "is", "not", "None", ":", "raise", "ValueError", "(", "\"The Grouper cannot specify both a key ...
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
[ "given", "an", "object", "and", "the", "specifications", "setup", "the", "internal", "grouper", "for", "this", "particular", "specification" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/grouper.py#L133-L192
19,445
pandas-dev/pandas
pandas/core/missing.py
_interpolate_scipy_wrapper
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...
python
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", ")", ":", "try", ":", "from", "scipy", "import"...
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.
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L242-L311
19,446
pandas-dev/pandas
pandas/core/missing.py
_from_derivatives
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 : ...
python
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", ")", ":", "from", "scipy", "import", "interpolate", "# return the method for compat with scipy version & backwards compat...
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...
[ "Convenience", "function", "for", "interpolate", ".", "BPoly", ".", "from_derivatives", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L314-L355
19,447
pandas-dev/pandas
pandas/core/missing.py
interpolate_2d
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...
python
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", ")", ":", "transf", "=", "(", "lambda", "x", ":", "x", ")", "if", "a...
Perform an actual interpolation of values, values will be make 2-d if needed fills inplace, returns the result.
[ "Perform", "an", "actual", "interpolation", "of", "values", "values", "will", "be", "make", "2", "-", "d", "if", "needed", "fills", "inplace", "returns", "the", "result", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L408-L442
19,448
pandas-dev/pandas
pandas/core/missing.py
_cast_values_for_fillna
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...
python
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", ")", ":", "# 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"...
Cast values to a dtype that algos.pad and algos.backfill can handle.
[ "Cast", "values", "to", "a", "dtype", "that", "algos", ".", "pad", "and", "algos", ".", "backfill", "can", "handle", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L445-L460
19,449
pandas-dev/pandas
pandas/core/missing.py
fill_zeros
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 ...
python
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", "fill", "is", "None", "or", "is_float_dtype", "(", "result", ")", ":", "return", "result", "if", "name", ".", "startswith", "(", "(", "'r'", ",", "'__...
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", "this", "is", "a", "reversed", "op", "then", "flip", "x", "y" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L524-L576
19,450
pandas-dev/pandas
pandas/core/missing.py
dispatch_missing
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) ...
python
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", ")", ":", "opstr", "=", "'__{opname}__'", ".", "format", "(", "opname", "=", "op", ".", "__name__", ")", ".", "replace", "(", "'____'", ",", "'__'", ")", "if", "op", "in"...
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 : ...
[ "Fill", "nulls", "caused", "by", "division", "by", "zero", "casting", "to", "a", "diffferent", "dtype", "if", "necessary", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L631-L657
19,451
pandas-dev/pandas
pandas/core/missing.py
_interp_limit
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 ...
python
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", ")", ":", "# 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", ")", ...
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 --...
[ "Get", "indexers", "of", "values", "that", "won", "t", "be", "filled", "because", "they", "exceed", "the", "limits", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L660-L721
19,452
pandas-dev/pandas
pandas/io/formats/console.py
in_interactive_session
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...
python
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", "(", ")", ":", "from", "pandas", "import", "get_option", "def", "check_main", "(", ")", ":", "try", ":", "import", "__main__", "as", "main", "except", "ModuleNotFoundError", ":", "return", "get_option", "(", "'mode.sim_interactive'...
check if we're running in an interactive shell returns True if running under python/ipython interactive shell
[ "check", "if", "we", "re", "running", "in", "an", "interactive", "shell" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/console.py#L51-L69
19,453
pandas-dev/pandas
pandas/core/groupby/categorical.py
recode_for_groupby
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...
python
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", ")", ":", "# we only care about observed values", "if", "observed", ":", "unique_codes", "=", "unique1d", "(", "c", ".", "codes", ")", "take_codes", "=", "unique_codes", "[", "unique_codes", "!...
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, ...
[ "Code", "the", "categories", "to", "ensure", "we", "can", "groupby", "for", "categoricals", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/categorical.py#L8-L74
19,454
pandas-dev/pandas
pandas/io/parquet.py
get_engine
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...
python
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", ")", ":", "if", "engine", "==", "'auto'", ":", "engine", "=", "get_option", "(", "'io.parquet.engine'", ")", "if", "engine", "==", "'auto'", ":", "# try engines in this order", "try", ":", "return", "PyArrowImpl", "(", ")", ...
return our implementation
[ "return", "our", "implementation" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parquet.py#L13-L42
19,455
pandas-dev/pandas
pandas/io/parquet.py
to_parquet
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 ...
python
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", ")", ":", "impl", "=", "get_engine", "(", "engine", ...
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...
[ "Write", "a", "DataFrame", "to", "the", "parquet", "format", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parquet.py#L213-L251
19,456
pandas-dev/pandas
pandas/core/groupby/ops.py
generate_bins_generic
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...
python
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", ")", ":", "lenidx", "=", "len", "(", "values", ")", "lenbin", "=", "len", "(", "binner", ")", "if", "lenidx", "<=", "0", "or", "lenbin", "<=", "0", ":", "raise", "ValueError",...
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...
[ "Generate", "bin", "edge", "offsets", "and", "bin", "labels", "for", "one", "array", "using", "another", "array", "which", "has", "bin", "edge", "values", ".", "Both", "arrays", "must", "be", "sorted", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/ops.py#L40-L89
19,457
pandas-dev/pandas
pandas/core/groupby/ops.py
BaseGrouper.size
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...
python
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", ")", ":", "ids", ",", "_", ",", "ngroup", "=", "self", ".", "group_info", "ids", "=", "ensure_platform_int", "(", "ids", ")", "if", "ngroup", ":", "out", "=", "np", ".", "bincount", "(", "ids", "[", "ids", "!=", "-", "...
Compute group sizes
[ "Compute", "group", "sizes" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/ops.py#L241-L254
19,458
pandas-dev/pandas
pandas/core/reshape/melt.py
lreshape
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 ...
python
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", ")", ":", "if", "isinstance", "(", "groups", ",", "dict", ")", ":", "keys", "=", "list", "(", "groups", ".", "keys", "(", ")", ")", "values", "=...
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], ... ...
[ "Reshape", "long", "-", "format", "data", "to", "wide", ".", "Generalized", "inverse", "of", "DataFrame", ".", "pivot" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/melt.py#L108-L175
19,459
pandas-dev/pandas
pandas/core/reshape/melt.py
wide_to_long
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 ...
python
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+'", ")", ":", "def", "get_var_names", "(", "df", ",", "stub", ",", "sep", ",", "suffix", ")", ":", "regex", "=", "r'^{stub}{...
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...
[ "r", "Wide", "panel", "to", "long", "format", ".", "Less", "flexible", "but", "more", "user", "-", "friendly", "than", "melt", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/melt.py#L178-L458
19,460
pandas-dev/pandas
pandas/core/groupby/groupby.py
_GroupBy._get_indices
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...
python
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", ")", ":", "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", ",", ...
Safe get multiple indices, translate keys for datelike to underlying repr.
[ "Safe", "get", "multiple", "indices", "translate", "keys", "for", "datelike", "to", "underlying", "repr", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L409-L457
19,461
pandas-dev/pandas
pandas/core/groupby/groupby.py
_GroupBy._set_group_selection
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 ...
python
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", ")", ":", "grp", "=", "self", ".", "grouper", "if", "not", "(", "self", ".", "as_index", "and", "getattr", "(", "grp", ",", "'groupings'", ",", "None", ")", "is", "not", "None", "and", "self", ".", "obj", "...
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
[ "Create", "group", "based", "selection", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L487-L510
19,462
pandas-dev/pandas
pandas/core/groupby/groupby.py
_GroupBy.get_group
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 ...
python
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", ")", ":", "if", "obj", "is", "None", ":", "obj", "=", "self", ".", "_selected_obj", "inds", "=", "self", ".", "_get_index", "(", "name", ")", "if", "not", "len", "(", "inds", ...
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...
[ "Construct", "NDFrame", "from", "group", "with", "provided", "name", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L630-L654
19,463
pandas-dev/pandas
pandas/core/groupby/groupby.py
_GroupBy._try_cast
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 > ...
python
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", ")", ":", "if", "obj", ".", "ndim", ">", "1", ":", "dtype", "=", "obj", ".", "_values", ".", "dtype", "else", ":", "dtype", "=", "obj", ".", "dtype", "...
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.
[ "Try", "to", "cast", "the", "result", "to", "our", "obj", "original", "type", "we", "may", "have", "roundtripped", "through", "object", "in", "the", "mean", "-", "time", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L756-L799
19,464
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy.sem
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...
python
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", ")", ":", "return", "self", ".", "std", "(", "ddof", "=", "ddof", ")", "/", "np", ".", "sqrt", "(", "self", ".", "count", "(", ")", ")" ]
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
[ "Compute", "standard", "error", "of", "the", "mean", "of", "groups", "excluding", "missing", "values", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1224-L1236
19,465
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy.size
def size(self): """ Compute group sizes. """ result = self.grouper.size() if isinstance(self.obj, Series): result.name = getattr(self.obj, 'name', None) return result
python
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", ")", ":", "result", "=", "self", ".", "grouper", ".", "size", "(", ")", "if", "isinstance", "(", "self", ".", "obj", ",", "Series", ")", ":", "result", ".", "name", "=", "getattr", "(", "self", ".", "obj", ",", "'name'...
Compute group sizes.
[ "Compute", "group", "sizes", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1240-L1248
19,466
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy._add_numeric_operations
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)...
python
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", ")", ":", "def", "groupby_function", "(", "name", ",", "alias", ",", "npfunc", ",", "numeric_only", "=", "True", ",", "_convert", "=", "False", ",", "min_count", "=", "-", "1", ")", ":", "_local_template", "=",...
Add numeric operations to the GroupBy generically.
[ "Add", "numeric", "operations", "to", "the", "GroupBy", "generically", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1251-L1324
19,467
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy.resample
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...
python
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", ")", ":", "from", "pandas", ".", "core", ".", "resample", "import", "get_resampler_for_grouping", "return", "get_resampler_for_grouping", "(", "self", ",", "rule", ",", ...
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 ...
[ "Provide", "resampling", "when", "using", "a", "TimeGrouper", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1346-L1453
19,468
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy.rolling
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)
python
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", ")", ":", "from", "pandas", ".", "core", ".", "window", "import", "RollingGroupby", "return", "RollingGroupby", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Return a rolling grouper, providing rolling functionality per group.
[ "Return", "a", "rolling", "grouper", "providing", "rolling", "functionality", "per", "group", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1457-L1462
19,469
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy.expanding
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)
python
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", ")", ":", "from", "pandas", ".", "core", ".", "window", "import", "ExpandingGroupby", "return", "ExpandingGroupby", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")" ...
Return an expanding grouper, providing expanding functionality per group.
[ "Return", "an", "expanding", "grouper", "providing", "expanding", "functionality", "per", "group", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1466-L1472
19,470
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy._fill
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...
python
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", ")", ":", "# Need int value for Cython", "if", "limit", "is", "None", ":", "limit", "=", "-", "1", "return", "self", ".", "_get_cythonized_result", "(", "'group_fillna_indexer'", ",", ...
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...
[ "Shared", "function", "for", "pad", "and", "backfill", "to", "call", "Cython", "method", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1474-L1505
19,471
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy.quantile
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...
python
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'", ")", ":", "def", "pre_processor", "(", "vals", ":", "np", ".", "ndarray", ")", "->", "Tuple", "[", "np", ".", "ndarray", ",", "Optional", "[", "Type", "]", ...
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'} ...
[ "Return", "group", "values", "at", "the", "given", "quantile", "a", "la", "numpy", ".", "percentile", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1707-L1777
19,472
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy.ngroup
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...
python
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", ")", ":", "with", "_group_selection_context", "(", "self", ")", ":", "index", "=", "self", ".", "_selected_obj", ".", "index", "result", "=", "Series", "(", "self", ".", "grouper", ".", "group_...
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...
[ "Number", "each", "group", "from", "0", "to", "the", "number", "of", "groups", "-", "1", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1780-L1843
19,473
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy.cumcount
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...
python
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", ")", ":", "with", "_group_selection_context", "(", "self", ")", ":", "index", "=", "self", ".", "_selected_obj", ".", "index", "cumcounts", "=", "self", ".", "_cumcount_array", "(", "ascending", ...
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...
[ "Number", "each", "item", "in", "each", "group", "from", "0", "to", "the", "length", "of", "that", "group", "-", "1", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1846-L1897
19,474
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy.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...
python
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", ")", ":", "if", "na_option", "not", "in", "{", "'keep'", ",", "'top'", ","...
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...
[ "Provide", "the", "rank", "of", "values", "within", "each", "group", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1901-L1934
19,475
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy.cumprod
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...
python
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", ")", ":", "nv", ".", "validate_groupby_func", "(", "'cumprod'", ",", "args", ",", "kwargs", ",", "[", "'numeric_only'", ",", "'skipna'", "]", ")", "if", ...
Cumulative product for each group.
[ "Cumulative", "product", "for", "each", "group", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1938-L1947
19,476
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy.cummin
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)
python
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", ")", ":", "if", "axis", "!=", "0", ":", "return", "self", ".", "apply", "(", "lambda", "x", ":", "np", ".", "minimum", ".", "accumulate", "(", "x", ",", "axis", ")", ...
Cumulative min for each group.
[ "Cumulative", "min", "for", "each", "group", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1964-L1971
19,477
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy.cummax
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)
python
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", ")", ":", "if", "axis", "!=", "0", ":", "return", "self", ".", "apply", "(", "lambda", "x", ":", "np", ".", "maximum", ".", "accumulate", "(", "x", ",", "axis", ")", ...
Cumulative max for each group.
[ "Cumulative", "max", "for", "each", "group", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1975-L1982
19,478
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy._get_cythonized_result
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...
python
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_i...
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 ...
[ "Get", "result", "for", "Cythonized", "functions", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1984-L2088
19,479
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy.shift
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 ...
python
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", ")", ":", "if", "freq", "is", "not", "None", "or", "axis", "!=", "0", "or", "not", "isna", "(", "fill_value", ...
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
[ "Shift", "each", "group", "by", "periods", "observations", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L2092-L2115
19,480
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy.head
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]], ...
python
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", ")", ":", "self", ".", "_reset_group_selection", "(", ")", "mask", "=", "self", ".", "_cumcount_array", "(", ")", "<", "n", "return", "self", ".", "_selected_obj", "[", "mask", "]" ]
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...
[ "Return", "first", "n", "rows", "of", "each", "group", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L2137-L2160
19,481
pandas-dev/pandas
pandas/core/groupby/groupby.py
GroupBy.tail
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]], ...
python
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", ")", ":", "self", ".", "_reset_group_selection", "(", ")", "mask", "=", "self", ".", "_cumcount_array", "(", "ascending", "=", "False", ")", "<", "n", "return", "self", ".", "_selected_obj", "[", "mask", ...
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']) ...
[ "Return", "last", "n", "rows", "of", "each", "group", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L2164-L2187
19,482
pandas-dev/pandas
pandas/tseries/holiday.py
next_monday
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
python
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", "dt", ".", "weekday", "(", ")", "==", "5", ":", "return", "dt", "+", "timedelta", "(", "2", ")", "elif", "dt", ".", "weekday", "(", ")", "==", "6", ":", "return", "dt", "+", "timedelta", "(", "1"...
If holiday falls on Saturday, use following Monday instead; if holiday falls on Sunday, use Monday instead
[ "If", "holiday", "falls", "on", "Saturday", "use", "following", "Monday", "instead", ";", "if", "holiday", "falls", "on", "Sunday", "use", "Monday", "instead" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L15-L24
19,483
pandas-dev/pandas
pandas/tseries/holiday.py
previous_friday
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
python
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", "dt", ".", "weekday", "(", ")", "==", "5", ":", "return", "dt", "-", "timedelta", "(", "1", ")", "elif", "dt", ".", "weekday", "(", ")", "==", "6", ":", "return", "dt", "-", "timedelta", "(", ...
If holiday falls on Saturday or Sunday, use previous Friday instead.
[ "If", "holiday", "falls", "on", "Saturday", "or", "Sunday", "use", "previous", "Friday", "instead", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L42-L50
19,484
pandas-dev/pandas
pandas/tseries/holiday.py
next_workday
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
python
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", ")", ":", "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
[ "returns", "next", "weekday", "used", "for", "observances" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L87-L95
19,485
pandas-dev/pandas
pandas/tseries/holiday.py
previous_workday
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
python
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", ")", ":", "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
[ "returns", "previous", "weekday", "used", "for", "observances" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L98-L106
19,486
pandas-dev/pandas
pandas/tseries/holiday.py
Holiday.dates
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,...
python
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", ")", ":", "start_date", "=", "Timestamp", "(", "start_date", ")", "end_date", "=", "Timestamp", "(", "end_date", ")", "filter_start_date", "=", "start_date", "...
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...
[ "Calculate", "holidays", "observed", "between", "start", "date", "and", "end", "date" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L192-L233
19,487
pandas-dev/pandas
pandas/tseries/holiday.py
Holiday._reference_dates
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...
python
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", ")", ":", "if", "self", ".", "start_date", "is", "not", "None", ":", "start_date", "=", "self", ".", "start_date", ".", "tz_localize", "(", "start_date", ".", "tz", ")", "if", "s...
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.
[ "Get", "reference", "dates", "for", "the", "holiday", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L235-L261
19,488
pandas-dev/pandas
pandas/tseries/holiday.py
AbstractHolidayCalendar.holidays
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...
python
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", ")", ":", "if", "self", ".", "rules", "is", "None", ":", "raise", "Exception", "(", "'Holiday Calendar {name} does not have any '", "'rules ...
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. ...
[ "Returns", "a", "curve", "with", "holidays", "between", "start_date", "and", "end_date" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L362-L412
19,489
pandas-dev/pandas
pandas/tseries/holiday.py
AbstractHolidayCalendar.merge_class
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 ...
python
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", ")", ":", "try", ":", "other", "=", "other", ".", "rules", "except", "AttributeError", ":", "pass", "if", "not", "isinstance", "(", "other", ",", "list", ")", ":", "other", "=", "[", "other", "]", "oth...
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...
[ "Merge", "holiday", "calendars", "together", ".", "The", "base", "calendar", "will", "take", "precedence", "to", "other", ".", "The", "merge", "will", "be", "done", "based", "on", "each", "holiday", "s", "name", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L415-L447
19,490
pandas-dev/pandas
pandas/tseries/holiday.py
AbstractHolidayCalendar.merge
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) ...
python
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", ")", ":", "holidays", "=", "self", ".", "merge_class", "(", "self", ",", "other", ")", "if", "inplace", ":", "self", ".", "rules", "=", "holidays", "else", ":", "return", "holid...
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...
[ "Merge", "holiday", "calendars", "together", ".", "The", "caller", "s", "class", "rules", "take", "precedence", ".", "The", "merge", "will", "be", "done", "based", "on", "each", "holiday", "s", "name", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/holiday.py#L449-L465
19,491
pandas-dev/pandas
pandas/_config/config.py
register_option
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...
python
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", ")", ":", "import", "tokenize", "import", "keyword", "key", "=", "key", ".", "lower", "(", ")", "if", "key", "in", "_...
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...
[ "Register", "an", "option", "in", "the", "package", "-", "wide", "pandas", "config", "object" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/config.py#L415-L479
19,492
pandas-dev/pandas
pandas/_config/config.py
deprecate_option
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...
python
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", ")", ":", "key", "=", "key", ".", "lower", "(", ")", "if", "key", "in", "_deprecated_options", ":", "msg", "=", "\"Option '{key}'...
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...
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/config.py#L482-L527
19,493
pandas-dev/pandas
pandas/_config/config.py
_select_options
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...
python
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", ")", ":", "# short-circuit for exact key", "if", "pat", "in", "_registered_options", ":", "return", "[", "pat", "]", "# else look through all of them", "keys", "=", "sorted", "(", "_registered_options", ".", "keys", "(", ")", ...
returns a list of keys matching `pat` if pat=="all", returns all registered options
[ "returns", "a", "list", "of", "keys", "matching", "pat" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/config.py#L533-L548
19,494
pandas-dev/pandas
pandas/_config/config.py
_translate_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
python
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", ")", ":", "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
[ "if", "key", "id", "deprecated", "and", "a", "replacement", "key", "defined", "will", "return", "the", "replacement", "key", "otherwise", "returns", "key", "as", "-", "is" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/config.py#L594-L604
19,495
pandas-dev/pandas
pandas/_config/config.py
_build_option_description
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...
python
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", ")", ":", "o", "=", "_get_registered_option", "(", "k", ")", "d", "=", "_get_deprecated_option", "(", "k", ")", "s", "=", "'{k} '", ".", "format", "(", "k", "=", "k", ")", "if", "o", ".", "doc", ":", "s",...
Builds a formatted description of a registered option and prints it
[ "Builds", "a", "formatted", "description", "of", "a", "registered", "option", "and", "prints", "it" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/config.py#L636-L659
19,496
pandas-dev/pandas
pandas/_config/config.py
config_prefix
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....
python
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", ")", ":", "# 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", "(", ...
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....
[ "contextmanager", "for", "multiple", "invocations", "of", "API", "with", "a", "common", "prefix" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/config.py#L696-L741
19,497
pandas-dev/pandas
pandas/core/arrays/interval.py
maybe_convert_platform_interval
def maybe_convert_platform_interval(values): """ Try to do platform conversion, with special casing for IntervalArray. Wrapper around maybe_convert_platform that alters the default return dtype in certain cases to be compatible with IntervalArray. For example, empty lists return with integer dtype ...
python
def maybe_convert_platform_interval(values): """ Try to do platform conversion, with special casing for IntervalArray. Wrapper around maybe_convert_platform that alters the default return dtype in certain cases to be compatible with IntervalArray. For example, empty lists return with integer dtype ...
[ "def", "maybe_convert_platform_interval", "(", "values", ")", ":", "if", "isinstance", "(", "values", ",", "(", "list", ",", "tuple", ")", ")", "and", "len", "(", "values", ")", "==", "0", ":", "# GH 19016", "# empty lists/tuples get object dtype by default, but t...
Try to do platform conversion, with special casing for IntervalArray. Wrapper around maybe_convert_platform that alters the default return dtype in certain cases to be compatible with IntervalArray. For example, empty lists return with integer dtype instead of object dtype, which is prohibited for Inte...
[ "Try", "to", "do", "platform", "conversion", "with", "special", "casing", "for", "IntervalArray", ".", "Wrapper", "around", "maybe_convert_platform", "that", "alters", "the", "default", "return", "dtype", "in", "certain", "cases", "to", "be", "compatible", "with",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/interval.py#L1078-L1102
19,498
pandas-dev/pandas
pandas/core/dtypes/inference.py
is_file_like
def is_file_like(obj): """ Check if the object is a file-like object. For objects to be considered file-like, they must be an iterator AND have either a `read` and/or `write` method as an attribute. Note: file-like objects must be iterable, but iterable objects need not be file-like. ...
python
def is_file_like(obj): """ Check if the object is a file-like object. For objects to be considered file-like, they must be an iterator AND have either a `read` and/or `write` method as an attribute. Note: file-like objects must be iterable, but iterable objects need not be file-like. ...
[ "def", "is_file_like", "(", "obj", ")", ":", "if", "not", "(", "hasattr", "(", "obj", ",", "'read'", ")", "or", "hasattr", "(", "obj", ",", "'write'", ")", ")", ":", "return", "False", "if", "not", "hasattr", "(", "obj", ",", "\"__iter__\"", ")", "...
Check if the object is a file-like object. For objects to be considered file-like, they must be an iterator AND have either a `read` and/or `write` method as an attribute. Note: file-like objects must be iterable, but iterable objects need not be file-like. .. versionadded:: 0.20.0 Param...
[ "Check", "if", "the", "object", "is", "a", "file", "-", "like", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/inference.py#L152-L189
19,499
pandas-dev/pandas
pandas/core/dtypes/inference.py
is_list_like
def is_list_like(obj, allow_sets=True): """ Check if the object is list-like. Objects that are considered list-like are for example Python lists, tuples, sets, NumPy arrays, and Pandas Series. Strings and datetime objects, however, are not considered list-like. Parameters ---------- o...
python
def is_list_like(obj, allow_sets=True): """ Check if the object is list-like. Objects that are considered list-like are for example Python lists, tuples, sets, NumPy arrays, and Pandas Series. Strings and datetime objects, however, are not considered list-like. Parameters ---------- o...
[ "def", "is_list_like", "(", "obj", ",", "allow_sets", "=", "True", ")", ":", "return", "(", "isinstance", "(", "obj", ",", "abc", ".", "Iterable", ")", "and", "# we do not count strings/unicode/bytes as list-like", "not", "isinstance", "(", "obj", ",", "(", "s...
Check if the object is list-like. Objects that are considered list-like are for example Python lists, tuples, sets, NumPy arrays, and Pandas Series. Strings and datetime objects, however, are not considered list-like. Parameters ---------- obj : The object to check allow_sets : boolean, d...
[ "Check", "if", "the", "object", "is", "list", "-", "like", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/inference.py#L245-L293