partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | masked_rec_array_to_mgr | Extract from a masked rec array and create the manager. | pandas/core/internals/construction.py | def masked_rec_array_to_mgr(data, index, columns, dtype, copy):
"""
Extract from a masked rec array and create the manager.
"""
# essentially process a record array then fill it
fill_value = data.fill_value
fdata = ma.getdata(data)
if index is None:
index = get_names_from_index(fdat... | def masked_rec_array_to_mgr(data, index, columns, dtype, copy):
"""
Extract from a masked rec array and create the manager.
"""
# essentially process a record array then fill it
fill_value = data.fill_value
fdata = ma.getdata(data)
if index is None:
index = get_names_from_index(fdat... | [
"Extract",
"from",
"a",
"masked",
"rec",
"array",
"and",
"create",
"the",
"manager",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/construction.py#L62-L98 | [
"def",
"masked_rec_array_to_mgr",
"(",
"data",
",",
"index",
",",
"columns",
",",
"dtype",
",",
"copy",
")",
":",
"# essentially process a record array then fill it",
"fill_value",
"=",
"data",
".",
"fill_value",
"fdata",
"=",
"ma",
".",
"getdata",
"(",
"data",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | init_dict | Segregate Series based on type and coerce into matrices.
Needs to handle a lot of exceptional cases. | pandas/core/internals/construction.py | def init_dict(data, index, columns, dtype=None):
"""
Segregate Series based on type and coerce into matrices.
Needs to handle a lot of exceptional cases.
"""
if columns is not None:
from pandas.core.series import Series
arrays = Series(data, index=columns, dtype=object)
data_... | def init_dict(data, index, columns, dtype=None):
"""
Segregate Series based on type and coerce into matrices.
Needs to handle a lot of exceptional cases.
"""
if columns is not None:
from pandas.core.series import Series
arrays = Series(data, index=columns, dtype=object)
data_... | [
"Segregate",
"Series",
"based",
"on",
"type",
"and",
"coerce",
"into",
"matrices",
".",
"Needs",
"to",
"handle",
"a",
"lot",
"of",
"exceptional",
"cases",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/construction.py#L168-L204 | [
"def",
"init_dict",
"(",
"data",
",",
"index",
",",
"columns",
",",
"dtype",
"=",
"None",
")",
":",
"if",
"columns",
"is",
"not",
"None",
":",
"from",
"pandas",
".",
"core",
".",
"series",
"import",
"Series",
"arrays",
"=",
"Series",
"(",
"data",
","... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | to_arrays | Return list of arrays, columns. | pandas/core/internals/construction.py | def to_arrays(data, columns, coerce_float=False, dtype=None):
"""
Return list of arrays, columns.
"""
if isinstance(data, ABCDataFrame):
if columns is not None:
arrays = [data._ixs(i, axis=1).values
for i, col in enumerate(data.columns) if col in columns]
... | def to_arrays(data, columns, coerce_float=False, dtype=None):
"""
Return list of arrays, columns.
"""
if isinstance(data, ABCDataFrame):
if columns is not None:
arrays = [data._ixs(i, axis=1).values
for i, col in enumerate(data.columns) if col in columns]
... | [
"Return",
"list",
"of",
"arrays",
"columns",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/construction.py#L374-L418 | [
"def",
"to_arrays",
"(",
"data",
",",
"columns",
",",
"coerce_float",
"=",
"False",
",",
"dtype",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"ABCDataFrame",
")",
":",
"if",
"columns",
"is",
"not",
"None",
":",
"arrays",
"=",
"[",
"d... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | sanitize_index | Sanitize an index type to return an ndarray of the underlying, pass
through a non-Index. | pandas/core/internals/construction.py | def sanitize_index(data, index, copy=False):
"""
Sanitize an index type to return an ndarray of the underlying, pass
through a non-Index.
"""
if index is None:
return data
if len(data) != len(index):
raise ValueError('Length of values does not match length of index')
if is... | def sanitize_index(data, index, copy=False):
"""
Sanitize an index type to return an ndarray of the underlying, pass
through a non-Index.
"""
if index is None:
return data
if len(data) != len(index):
raise ValueError('Length of values does not match length of index')
if is... | [
"Sanitize",
"an",
"index",
"type",
"to",
"return",
"an",
"ndarray",
"of",
"the",
"underlying",
"pass",
"through",
"a",
"non",
"-",
"Index",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/construction.py#L501-L526 | [
"def",
"sanitize_index",
"(",
"data",
",",
"index",
",",
"copy",
"=",
"False",
")",
":",
"if",
"index",
"is",
"None",
":",
"return",
"data",
"if",
"len",
"(",
"data",
")",
"!=",
"len",
"(",
"index",
")",
":",
"raise",
"ValueError",
"(",
"'Length of v... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | sanitize_array | Sanitize input data to an ndarray, copy if specified, coerce to the
dtype if specified. | pandas/core/internals/construction.py | def sanitize_array(data, index, dtype=None, copy=False,
raise_cast_failure=False):
"""
Sanitize input data to an ndarray, copy if specified, coerce to the
dtype if specified.
"""
if dtype is not None:
dtype = pandas_dtype(dtype)
if isinstance(data, ma.MaskedArray):
... | def sanitize_array(data, index, dtype=None, copy=False,
raise_cast_failure=False):
"""
Sanitize input data to an ndarray, copy if specified, coerce to the
dtype if specified.
"""
if dtype is not None:
dtype = pandas_dtype(dtype)
if isinstance(data, ma.MaskedArray):
... | [
"Sanitize",
"input",
"data",
"to",
"an",
"ndarray",
"copy",
"if",
"specified",
"coerce",
"to",
"the",
"dtype",
"if",
"specified",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/construction.py#L529-L672 | [
"def",
"sanitize_array",
"(",
"data",
",",
"index",
",",
"dtype",
"=",
"None",
",",
"copy",
"=",
"False",
",",
"raise_cast_failure",
"=",
"False",
")",
":",
"if",
"dtype",
"is",
"not",
"None",
":",
"dtype",
"=",
"pandas_dtype",
"(",
"dtype",
")",
"if",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _check_engine | Make sure a valid engine is passed.
Parameters
----------
engine : str
Raises
------
KeyError
* If an invalid engine is passed
ImportError
* If numexpr was requested but doesn't exist
Returns
-------
string engine | pandas/core/computation/eval.py | def _check_engine(engine):
"""Make sure a valid engine is passed.
Parameters
----------
engine : str
Raises
------
KeyError
* If an invalid engine is passed
ImportError
* If numexpr was requested but doesn't exist
Returns
-------
string engine
"""
from... | def _check_engine(engine):
"""Make sure a valid engine is passed.
Parameters
----------
engine : str
Raises
------
KeyError
* If an invalid engine is passed
ImportError
* If numexpr was requested but doesn't exist
Returns
-------
string engine
"""
from... | [
"Make",
"sure",
"a",
"valid",
"engine",
"is",
"passed",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/eval.py#L17-L59 | [
"def",
"_check_engine",
"(",
"engine",
")",
":",
"from",
"pandas",
".",
"core",
".",
"computation",
".",
"check",
"import",
"_NUMEXPR_INSTALLED",
"if",
"engine",
"is",
"None",
":",
"if",
"_NUMEXPR_INSTALLED",
":",
"engine",
"=",
"'numexpr'",
"else",
":",
"en... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _check_parser | Make sure a valid parser is passed.
Parameters
----------
parser : str
Raises
------
KeyError
* If an invalid parser is passed | pandas/core/computation/eval.py | def _check_parser(parser):
"""Make sure a valid parser is passed.
Parameters
----------
parser : str
Raises
------
KeyError
* If an invalid parser is passed
"""
from pandas.core.computation.expr import _parsers
if parser not in _parsers:
raise KeyError('Invalid p... | def _check_parser(parser):
"""Make sure a valid parser is passed.
Parameters
----------
parser : str
Raises
------
KeyError
* If an invalid parser is passed
"""
from pandas.core.computation.expr import _parsers
if parser not in _parsers:
raise KeyError('Invalid p... | [
"Make",
"sure",
"a",
"valid",
"parser",
"is",
"passed",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/eval.py#L62-L78 | [
"def",
"_check_parser",
"(",
"parser",
")",
":",
"from",
"pandas",
".",
"core",
".",
"computation",
".",
"expr",
"import",
"_parsers",
"if",
"parser",
"not",
"in",
"_parsers",
":",
"raise",
"KeyError",
"(",
"'Invalid parser {parser!r} passed, valid parsers are'",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | eval | Evaluate a Python expression as a string using various backends.
The following arithmetic operations are supported: ``+``, ``-``, ``*``,
``/``, ``**``, ``%``, ``//`` (python engine only) along with the following
boolean operations: ``|`` (or), ``&`` (and), and ``~`` (not).
Additionally, the ``'pandas'`... | pandas/core/computation/eval.py | def eval(expr, parser='pandas', engine=None, truediv=True,
local_dict=None, global_dict=None, resolvers=(), level=0,
target=None, inplace=False):
"""Evaluate a Python expression as a string using various backends.
The following arithmetic operations are supported: ``+``, ``-``, ``*``,
``/... | def eval(expr, parser='pandas', engine=None, truediv=True,
local_dict=None, global_dict=None, resolvers=(), level=0,
target=None, inplace=False):
"""Evaluate a Python expression as a string using various backends.
The following arithmetic operations are supported: ``+``, ``-``, ``*``,
``/... | [
"Evaluate",
"a",
"Python",
"expression",
"as",
"a",
"string",
"using",
"various",
"backends",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/eval.py#L155-L350 | [
"def",
"eval",
"(",
"expr",
",",
"parser",
"=",
"'pandas'",
",",
"engine",
"=",
"None",
",",
"truediv",
"=",
"True",
",",
"local_dict",
"=",
"None",
",",
"global_dict",
"=",
"None",
",",
"resolvers",
"=",
"(",
")",
",",
"level",
"=",
"0",
",",
"tar... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndexUIntEngine._codes_to_ints | Transform combination(s) of uint64 in one uint64 (each), in a strictly
monotonic way (i.e. respecting the lexicographic order of integer
combinations): see BaseMultiIndexCodesEngine documentation.
Parameters
----------
codes : 1- or 2-dimensional array of dtype uint64
... | pandas/core/indexes/multi.py | def _codes_to_ints(self, codes):
"""
Transform combination(s) of uint64 in one uint64 (each), in a strictly
monotonic way (i.e. respecting the lexicographic order of integer
combinations): see BaseMultiIndexCodesEngine documentation.
Parameters
----------
codes :... | def _codes_to_ints(self, codes):
"""
Transform combination(s) of uint64 in one uint64 (each), in a strictly
monotonic way (i.e. respecting the lexicographic order of integer
combinations): see BaseMultiIndexCodesEngine documentation.
Parameters
----------
codes :... | [
"Transform",
"combination",
"(",
"s",
")",
"of",
"uint64",
"in",
"one",
"uint64",
"(",
"each",
")",
"in",
"a",
"strictly",
"monotonic",
"way",
"(",
"i",
".",
"e",
".",
"respecting",
"the",
"lexicographic",
"order",
"of",
"integer",
"combinations",
")",
"... | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L49-L77 | [
"def",
"_codes_to_ints",
"(",
"self",
",",
"codes",
")",
":",
"# Shift the representation of each level by the pre-calculated number",
"# of bits:",
"codes",
"<<=",
"self",
".",
"offsets",
"# Now sum and OR are in fact interchangeable. This is a simple",
"# composition of the (disjun... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.from_arrays | Convert arrays to MultiIndex.
Parameters
----------
arrays : list / sequence of array-likes
Each array-like gives one level's value for each data point.
len(arrays) is the number of levels.
sortorder : int or None
Level of sortedness (must be lexicogr... | pandas/core/indexes/multi.py | def from_arrays(cls, arrays, sortorder=None, names=None):
"""
Convert arrays to MultiIndex.
Parameters
----------
arrays : list / sequence of array-likes
Each array-like gives one level's value for each data point.
len(arrays) is the number of levels.
... | def from_arrays(cls, arrays, sortorder=None, names=None):
"""
Convert arrays to MultiIndex.
Parameters
----------
arrays : list / sequence of array-likes
Each array-like gives one level's value for each data point.
len(arrays) is the number of levels.
... | [
"Convert",
"arrays",
"to",
"MultiIndex",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L292-L350 | [
"def",
"from_arrays",
"(",
"cls",
",",
"arrays",
",",
"sortorder",
"=",
"None",
",",
"names",
"=",
"None",
")",
":",
"error_msg",
"=",
"\"Input must be a list / sequence of array-likes.\"",
"if",
"not",
"is_list_like",
"(",
"arrays",
")",
":",
"raise",
"TypeErro... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.from_tuples | Convert list of tuples to MultiIndex.
Parameters
----------
tuples : list / sequence of tuple-likes
Each tuple is the index of one row/column.
sortorder : int or None
Level of sortedness (must be lexicographically sorted by that
level).
names ... | pandas/core/indexes/multi.py | def from_tuples(cls, tuples, sortorder=None, names=None):
"""
Convert list of tuples to MultiIndex.
Parameters
----------
tuples : list / sequence of tuple-likes
Each tuple is the index of one row/column.
sortorder : int or None
Level of sortednes... | def from_tuples(cls, tuples, sortorder=None, names=None):
"""
Convert list of tuples to MultiIndex.
Parameters
----------
tuples : list / sequence of tuple-likes
Each tuple is the index of one row/column.
sortorder : int or None
Level of sortednes... | [
"Convert",
"list",
"of",
"tuples",
"to",
"MultiIndex",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L353-L407 | [
"def",
"from_tuples",
"(",
"cls",
",",
"tuples",
",",
"sortorder",
"=",
"None",
",",
"names",
"=",
"None",
")",
":",
"if",
"not",
"is_list_like",
"(",
"tuples",
")",
":",
"raise",
"TypeError",
"(",
"'Input must be a list / sequence of tuple-likes.'",
")",
"eli... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.from_product | Make a MultiIndex from the cartesian product of multiple iterables.
Parameters
----------
iterables : list / sequence of iterables
Each iterable has unique labels for each level of the index.
sortorder : int or None
Level of sortedness (must be lexicographically ... | pandas/core/indexes/multi.py | def from_product(cls, iterables, sortorder=None, names=None):
"""
Make a MultiIndex from the cartesian product of multiple iterables.
Parameters
----------
iterables : list / sequence of iterables
Each iterable has unique labels for each level of the index.
s... | def from_product(cls, iterables, sortorder=None, names=None):
"""
Make a MultiIndex from the cartesian product of multiple iterables.
Parameters
----------
iterables : list / sequence of iterables
Each iterable has unique labels for each level of the index.
s... | [
"Make",
"a",
"MultiIndex",
"from",
"the",
"cartesian",
"product",
"of",
"multiple",
"iterables",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L410-L454 | [
"def",
"from_product",
"(",
"cls",
",",
"iterables",
",",
"sortorder",
"=",
"None",
",",
"names",
"=",
"None",
")",
":",
"from",
"pandas",
".",
"core",
".",
"arrays",
".",
"categorical",
"import",
"_factorize_from_iterables",
"from",
"pandas",
".",
"core",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.from_frame | Make a MultiIndex from a DataFrame.
.. versionadded:: 0.24.0
Parameters
----------
df : DataFrame
DataFrame to be converted to MultiIndex.
sortorder : int, optional
Level of sortedness (must be lexicographically sorted by that
level).
... | pandas/core/indexes/multi.py | def from_frame(cls, df, sortorder=None, names=None):
"""
Make a MultiIndex from a DataFrame.
.. versionadded:: 0.24.0
Parameters
----------
df : DataFrame
DataFrame to be converted to MultiIndex.
sortorder : int, optional
Level of sortedn... | def from_frame(cls, df, sortorder=None, names=None):
"""
Make a MultiIndex from a DataFrame.
.. versionadded:: 0.24.0
Parameters
----------
df : DataFrame
DataFrame to be converted to MultiIndex.
sortorder : int, optional
Level of sortedn... | [
"Make",
"a",
"MultiIndex",
"from",
"a",
"DataFrame",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L457-L516 | [
"def",
"from_frame",
"(",
"cls",
",",
"df",
",",
"sortorder",
"=",
"None",
",",
"names",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"df",
",",
"ABCDataFrame",
")",
":",
"raise",
"TypeError",
"(",
"\"Input must be a DataFrame\"",
")",
"column_na... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.set_levels | Set new levels on MultiIndex. Defaults to returning
new index.
Parameters
----------
levels : sequence or list of sequence
new level(s) to apply
level : int, level name, or sequence of int/level names (default None)
level(s) to set (None for all levels)
... | pandas/core/indexes/multi.py | def set_levels(self, levels, level=None, inplace=False,
verify_integrity=True):
"""
Set new levels on MultiIndex. Defaults to returning
new index.
Parameters
----------
levels : sequence or list of sequence
new level(s) to apply
lev... | def set_levels(self, levels, level=None, inplace=False,
verify_integrity=True):
"""
Set new levels on MultiIndex. Defaults to returning
new index.
Parameters
----------
levels : sequence or list of sequence
new level(s) to apply
lev... | [
"Set",
"new",
"levels",
"on",
"MultiIndex",
".",
"Defaults",
"to",
"returning",
"new",
"index",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L599-L664 | [
"def",
"set_levels",
"(",
"self",
",",
"levels",
",",
"level",
"=",
"None",
",",
"inplace",
"=",
"False",
",",
"verify_integrity",
"=",
"True",
")",
":",
"if",
"is_list_like",
"(",
"levels",
")",
"and",
"not",
"isinstance",
"(",
"levels",
",",
"Index",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.set_codes | Set new codes on MultiIndex. Defaults to returning
new index.
.. versionadded:: 0.24.0
New name for deprecated method `set_labels`.
Parameters
----------
codes : sequence or list of sequence
new codes to apply
level : int, level name, or sequence... | pandas/core/indexes/multi.py | def set_codes(self, codes, level=None, inplace=False,
verify_integrity=True):
"""
Set new codes on MultiIndex. Defaults to returning
new index.
.. versionadded:: 0.24.0
New name for deprecated method `set_labels`.
Parameters
----------
... | def set_codes(self, codes, level=None, inplace=False,
verify_integrity=True):
"""
Set new codes on MultiIndex. Defaults to returning
new index.
.. versionadded:: 0.24.0
New name for deprecated method `set_labels`.
Parameters
----------
... | [
"Set",
"new",
"codes",
"on",
"MultiIndex",
".",
"Defaults",
"to",
"returning",
"new",
"index",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L714-L779 | [
"def",
"set_codes",
"(",
"self",
",",
"codes",
",",
"level",
"=",
"None",
",",
"inplace",
"=",
"False",
",",
"verify_integrity",
"=",
"True",
")",
":",
"if",
"level",
"is",
"not",
"None",
"and",
"not",
"is_list_like",
"(",
"level",
")",
":",
"if",
"n... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.copy | Make a copy of this object. Names, dtype, levels and codes can be
passed and will be set on new copy.
Parameters
----------
names : sequence, optional
dtype : numpy dtype or pandas type, optional
levels : sequence, optional
codes : sequence, optional
Ret... | pandas/core/indexes/multi.py | def copy(self, names=None, dtype=None, levels=None, codes=None,
deep=False, _set_identity=False, **kwargs):
"""
Make a copy of this object. Names, dtype, levels and codes can be
passed and will be set on new copy.
Parameters
----------
names : sequence, opti... | def copy(self, names=None, dtype=None, levels=None, codes=None,
deep=False, _set_identity=False, **kwargs):
"""
Make a copy of this object. Names, dtype, levels and codes can be
passed and will be set on new copy.
Parameters
----------
names : sequence, opti... | [
"Make",
"a",
"copy",
"of",
"this",
"object",
".",
"Names",
"dtype",
"levels",
"and",
"codes",
"can",
"be",
"passed",
"and",
"will",
"be",
"set",
"on",
"new",
"copy",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L782-L821 | [
"def",
"copy",
"(",
"self",
",",
"names",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"levels",
"=",
"None",
",",
"codes",
"=",
"None",
",",
"deep",
"=",
"False",
",",
"_set_identity",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
"="... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.view | this is defined as a copy with the same identity | pandas/core/indexes/multi.py | def view(self, cls=None):
""" this is defined as a copy with the same identity """
result = self.copy()
result._id = self._id
return result | def view(self, cls=None):
""" this is defined as a copy with the same identity """
result = self.copy()
result._id = self._id
return result | [
"this",
"is",
"defined",
"as",
"a",
"copy",
"with",
"the",
"same",
"identity"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L827-L831 | [
"def",
"view",
"(",
"self",
",",
"cls",
"=",
"None",
")",
":",
"result",
"=",
"self",
".",
"copy",
"(",
")",
"result",
".",
"_id",
"=",
"self",
".",
"_id",
"return",
"result"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex._is_memory_usage_qualified | return a boolean if we need a qualified .info display | pandas/core/indexes/multi.py | def _is_memory_usage_qualified(self):
""" return a boolean if we need a qualified .info display """
def f(l):
return 'mixed' in l or 'string' in l or 'unicode' in l
return any(f(l) for l in self._inferred_type_levels) | def _is_memory_usage_qualified(self):
""" return a boolean if we need a qualified .info display """
def f(l):
return 'mixed' in l or 'string' in l or 'unicode' in l
return any(f(l) for l in self._inferred_type_levels) | [
"return",
"a",
"boolean",
"if",
"we",
"need",
"a",
"qualified",
".",
"info",
"display"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L866-L870 | [
"def",
"_is_memory_usage_qualified",
"(",
"self",
")",
":",
"def",
"f",
"(",
"l",
")",
":",
"return",
"'mixed'",
"in",
"l",
"or",
"'string'",
"in",
"l",
"or",
"'unicode'",
"in",
"l",
"return",
"any",
"(",
"f",
"(",
"l",
")",
"for",
"l",
"in",
"self... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex._nbytes | return the number of bytes in the underlying data
deeply introspect the level data if deep=True
include the engine hashtable
*this is in internal routine* | pandas/core/indexes/multi.py | def _nbytes(self, deep=False):
"""
return the number of bytes in the underlying data
deeply introspect the level data if deep=True
include the engine hashtable
*this is in internal routine*
"""
# for implementations with no useful getsizeof (PyPy)
objs... | def _nbytes(self, deep=False):
"""
return the number of bytes in the underlying data
deeply introspect the level data if deep=True
include the engine hashtable
*this is in internal routine*
"""
# for implementations with no useful getsizeof (PyPy)
objs... | [
"return",
"the",
"number",
"of",
"bytes",
"in",
"the",
"underlying",
"data",
"deeply",
"introspect",
"the",
"level",
"data",
"if",
"deep",
"=",
"True"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L884-L905 | [
"def",
"_nbytes",
"(",
"self",
",",
"deep",
"=",
"False",
")",
":",
"# for implementations with no useful getsizeof (PyPy)",
"objsize",
"=",
"24",
"level_nbytes",
"=",
"sum",
"(",
"i",
".",
"memory_usage",
"(",
"deep",
"=",
"deep",
")",
"for",
"i",
"in",
"se... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex._format_attrs | Return a list of tuples of the (attr,formatted_value) | pandas/core/indexes/multi.py | def _format_attrs(self):
"""
Return a list of tuples of the (attr,formatted_value)
"""
attrs = [
('levels', ibase.default_pprint(self._levels,
max_seq_items=False)),
('codes', ibase.default_pprint(self._codes,
... | def _format_attrs(self):
"""
Return a list of tuples of the (attr,formatted_value)
"""
attrs = [
('levels', ibase.default_pprint(self._levels,
max_seq_items=False)),
('codes', ibase.default_pprint(self._codes,
... | [
"Return",
"a",
"list",
"of",
"tuples",
"of",
"the",
"(",
"attr",
"formatted_value",
")"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L910-L923 | [
"def",
"_format_attrs",
"(",
"self",
")",
":",
"attrs",
"=",
"[",
"(",
"'levels'",
",",
"ibase",
".",
"default_pprint",
"(",
"self",
".",
"_levels",
",",
"max_seq_items",
"=",
"False",
")",
")",
",",
"(",
"'codes'",
",",
"ibase",
".",
"default_pprint",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex._set_names | Set new names on index. Each name has to be a hashable type.
Parameters
----------
values : str or sequence
name(s) to set
level : int, level name, or sequence of int/level names (default None)
If the index is a MultiIndex (hierarchical), level(s) to set (None
... | pandas/core/indexes/multi.py | def _set_names(self, names, level=None, validate=True):
"""
Set new names on index. Each name has to be a hashable type.
Parameters
----------
values : str or sequence
name(s) to set
level : int, level name, or sequence of int/level names (default None)
... | def _set_names(self, names, level=None, validate=True):
"""
Set new names on index. Each name has to be a hashable type.
Parameters
----------
values : str or sequence
name(s) to set
level : int, level name, or sequence of int/level names (default None)
... | [
"Set",
"new",
"names",
"on",
"index",
".",
"Each",
"name",
"has",
"to",
"be",
"a",
"hashable",
"type",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1026-L1076 | [
"def",
"_set_names",
"(",
"self",
",",
"names",
",",
"level",
"=",
"None",
",",
"validate",
"=",
"True",
")",
":",
"# GH 15110",
"# Don't allow a single string for names in a MultiIndex",
"if",
"names",
"is",
"not",
"None",
"and",
"not",
"is_list_like",
"(",
"na... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.is_monotonic_increasing | return if the index is monotonic increasing (only equal or
increasing) values. | pandas/core/indexes/multi.py | def is_monotonic_increasing(self):
"""
return if the index is monotonic increasing (only equal or
increasing) values.
"""
# reversed() because lexsort() wants the most significant key last.
values = [self._get_level_values(i).values
for i in reversed(ra... | def is_monotonic_increasing(self):
"""
return if the index is monotonic increasing (only equal or
increasing) values.
"""
# reversed() because lexsort() wants the most significant key last.
values = [self._get_level_values(i).values
for i in reversed(ra... | [
"return",
"if",
"the",
"index",
"is",
"monotonic",
"increasing",
"(",
"only",
"equal",
"or",
"increasing",
")",
"values",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1192-L1207 | [
"def",
"is_monotonic_increasing",
"(",
"self",
")",
":",
"# reversed() because lexsort() wants the most significant key last.",
"values",
"=",
"[",
"self",
".",
"_get_level_values",
"(",
"i",
")",
".",
"values",
"for",
"i",
"in",
"reversed",
"(",
"range",
"(",
"len"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex._hashed_indexing_key | validate and return the hash for the provided key
*this is internal for use for the cython routines*
Parameters
----------
key : string or tuple
Returns
-------
np.uint64
Notes
-----
we need to stringify if we have mixed levels | pandas/core/indexes/multi.py | def _hashed_indexing_key(self, key):
"""
validate and return the hash for the provided key
*this is internal for use for the cython routines*
Parameters
----------
key : string or tuple
Returns
-------
np.uint64
Notes
-----
... | def _hashed_indexing_key(self, key):
"""
validate and return the hash for the provided key
*this is internal for use for the cython routines*
Parameters
----------
key : string or tuple
Returns
-------
np.uint64
Notes
-----
... | [
"validate",
"and",
"return",
"the",
"hash",
"for",
"the",
"provided",
"key"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1234-L1267 | [
"def",
"_hashed_indexing_key",
"(",
"self",
",",
"key",
")",
":",
"from",
"pandas",
".",
"core",
".",
"util",
".",
"hashing",
"import",
"hash_tuples",
",",
"hash_tuple",
"if",
"not",
"isinstance",
"(",
"key",
",",
"tuple",
")",
":",
"return",
"hash_tuples"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex._get_level_values | Return vector of label values for requested level,
equal to the length of the index
**this is an internal method**
Parameters
----------
level : int level
unique : bool, default False
if True, drop duplicated values
Returns
-------
v... | pandas/core/indexes/multi.py | def _get_level_values(self, level, unique=False):
"""
Return vector of label values for requested level,
equal to the length of the index
**this is an internal method**
Parameters
----------
level : int level
unique : bool, default False
if T... | def _get_level_values(self, level, unique=False):
"""
Return vector of label values for requested level,
equal to the length of the index
**this is an internal method**
Parameters
----------
level : int level
unique : bool, default False
if T... | [
"Return",
"vector",
"of",
"label",
"values",
"for",
"requested",
"level",
"equal",
"to",
"the",
"length",
"of",
"the",
"index"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1357-L1382 | [
"def",
"_get_level_values",
"(",
"self",
",",
"level",
",",
"unique",
"=",
"False",
")",
":",
"values",
"=",
"self",
".",
"levels",
"[",
"level",
"]",
"level_codes",
"=",
"self",
".",
"codes",
"[",
"level",
"]",
"if",
"unique",
":",
"level_codes",
"=",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.get_level_values | Return vector of label values for requested level,
equal to the length of the index.
Parameters
----------
level : int or str
``level`` is either the integer position of the level in the
MultiIndex, or the name of the level.
Returns
-------
... | pandas/core/indexes/multi.py | def get_level_values(self, level):
"""
Return vector of label values for requested level,
equal to the length of the index.
Parameters
----------
level : int or str
``level`` is either the integer position of the level in the
MultiIndex, or the na... | def get_level_values(self, level):
"""
Return vector of label values for requested level,
equal to the length of the index.
Parameters
----------
level : int or str
``level`` is either the integer position of the level in the
MultiIndex, or the na... | [
"Return",
"vector",
"of",
"label",
"values",
"for",
"requested",
"level",
"equal",
"to",
"the",
"length",
"of",
"the",
"index",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1384-L1418 | [
"def",
"get_level_values",
"(",
"self",
",",
"level",
")",
":",
"level",
"=",
"self",
".",
"_get_level_number",
"(",
"level",
")",
"values",
"=",
"self",
".",
"_get_level_values",
"(",
"level",
")",
"return",
"values"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.to_frame | Create a DataFrame with the levels of the MultiIndex as columns.
Column ordering is determined by the DataFrame constructor with data as
a dict.
.. versionadded:: 0.24.0
Parameters
----------
index : boolean, default True
Set the index of the returned DataF... | pandas/core/indexes/multi.py | def to_frame(self, index=True, name=None):
"""
Create a DataFrame with the levels of the MultiIndex as columns.
Column ordering is determined by the DataFrame constructor with data as
a dict.
.. versionadded:: 0.24.0
Parameters
----------
index : boolea... | def to_frame(self, index=True, name=None):
"""
Create a DataFrame with the levels of the MultiIndex as columns.
Column ordering is determined by the DataFrame constructor with data as
a dict.
.. versionadded:: 0.24.0
Parameters
----------
index : boolea... | [
"Create",
"a",
"DataFrame",
"with",
"the",
"levels",
"of",
"the",
"MultiIndex",
"as",
"columns",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1433-L1484 | [
"def",
"to_frame",
"(",
"self",
",",
"index",
"=",
"True",
",",
"name",
"=",
"None",
")",
":",
"from",
"pandas",
"import",
"DataFrame",
"if",
"name",
"is",
"not",
"None",
":",
"if",
"not",
"is_list_like",
"(",
"name",
")",
":",
"raise",
"TypeError",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.to_hierarchical | Return a MultiIndex reshaped to conform to the
shapes given by n_repeat and n_shuffle.
.. deprecated:: 0.24.0
Useful to replicate and rearrange a MultiIndex for combination
with another Index with n_repeat items.
Parameters
----------
n_repeat : int
... | pandas/core/indexes/multi.py | def to_hierarchical(self, n_repeat, n_shuffle=1):
"""
Return a MultiIndex reshaped to conform to the
shapes given by n_repeat and n_shuffle.
.. deprecated:: 0.24.0
Useful to replicate and rearrange a MultiIndex for combination
with another Index with n_repeat items.
... | def to_hierarchical(self, n_repeat, n_shuffle=1):
"""
Return a MultiIndex reshaped to conform to the
shapes given by n_repeat and n_shuffle.
.. deprecated:: 0.24.0
Useful to replicate and rearrange a MultiIndex for combination
with another Index with n_repeat items.
... | [
"Return",
"a",
"MultiIndex",
"reshaped",
"to",
"conform",
"to",
"the",
"shapes",
"given",
"by",
"n_repeat",
"and",
"n_shuffle",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1486-L1528 | [
"def",
"to_hierarchical",
"(",
"self",
",",
"n_repeat",
",",
"n_shuffle",
"=",
"1",
")",
":",
"levels",
"=",
"self",
".",
"levels",
"codes",
"=",
"[",
"np",
".",
"repeat",
"(",
"level_codes",
",",
"n_repeat",
")",
"for",
"level_codes",
"in",
"self",
".... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex._sort_levels_monotonic | .. versionadded:: 0.20.0
This is an *internal* function.
Create a new MultiIndex from the current to monotonically sorted
items IN the levels. This does not actually make the entire MultiIndex
monotonic, JUST the levels.
The resulting MultiIndex will have the same outward
... | pandas/core/indexes/multi.py | def _sort_levels_monotonic(self):
"""
.. versionadded:: 0.20.0
This is an *internal* function.
Create a new MultiIndex from the current to monotonically sorted
items IN the levels. This does not actually make the entire MultiIndex
monotonic, JUST the levels.
Th... | def _sort_levels_monotonic(self):
"""
.. versionadded:: 0.20.0
This is an *internal* function.
Create a new MultiIndex from the current to monotonically sorted
items IN the levels. This does not actually make the entire MultiIndex
monotonic, JUST the levels.
Th... | [
"..",
"versionadded",
"::",
"0",
".",
"20",
".",
"0"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1583-L1643 | [
"def",
"_sort_levels_monotonic",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_lexsorted",
"(",
")",
"and",
"self",
".",
"is_monotonic",
":",
"return",
"self",
"new_levels",
"=",
"[",
"]",
"new_codes",
"=",
"[",
"]",
"for",
"lev",
",",
"level_codes",
"in... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.remove_unused_levels | Create a new MultiIndex from the current that removes
unused levels, meaning that they are not expressed in the labels.
The resulting MultiIndex will have the same outward
appearance, meaning the same .values and ordering. It will also
be .equals() to the original.
.. versionad... | pandas/core/indexes/multi.py | def remove_unused_levels(self):
"""
Create a new MultiIndex from the current that removes
unused levels, meaning that they are not expressed in the labels.
The resulting MultiIndex will have the same outward
appearance, meaning the same .values and ordering. It will also
... | def remove_unused_levels(self):
"""
Create a new MultiIndex from the current that removes
unused levels, meaning that they are not expressed in the labels.
The resulting MultiIndex will have the same outward
appearance, meaning the same .values and ordering. It will also
... | [
"Create",
"a",
"new",
"MultiIndex",
"from",
"the",
"current",
"that",
"removes",
"unused",
"levels",
"meaning",
"that",
"they",
"are",
"not",
"expressed",
"in",
"the",
"labels",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1645-L1725 | [
"def",
"remove_unused_levels",
"(",
"self",
")",
":",
"new_levels",
"=",
"[",
"]",
"new_codes",
"=",
"[",
"]",
"changed",
"=",
"False",
"for",
"lev",
",",
"level_codes",
"in",
"zip",
"(",
"self",
".",
"levels",
",",
"self",
".",
"codes",
")",
":",
"#... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex._assert_take_fillable | Internal method to handle NA filling of take | pandas/core/indexes/multi.py | def _assert_take_fillable(self, values, indices, allow_fill=True,
fill_value=None, na_value=None):
""" Internal method to handle NA filling of take """
# only fill if we are passing a non-None fill_value
if allow_fill and fill_value is not None:
if (indi... | def _assert_take_fillable(self, values, indices, allow_fill=True,
fill_value=None, na_value=None):
""" Internal method to handle NA filling of take """
# only fill if we are passing a non-None fill_value
if allow_fill and fill_value is not None:
if (indi... | [
"Internal",
"method",
"to",
"handle",
"NA",
"filling",
"of",
"take"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1806-L1826 | [
"def",
"_assert_take_fillable",
"(",
"self",
",",
"values",
",",
"indices",
",",
"allow_fill",
"=",
"True",
",",
"fill_value",
"=",
"None",
",",
"na_value",
"=",
"None",
")",
":",
"# only fill if we are passing a non-None fill_value",
"if",
"allow_fill",
"and",
"f... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.append | Append a collection of Index options together
Parameters
----------
other : Index or list/tuple of indices
Returns
-------
appended : Index | pandas/core/indexes/multi.py | def append(self, other):
"""
Append a collection of Index options together
Parameters
----------
other : Index or list/tuple of indices
Returns
-------
appended : Index
"""
if not isinstance(other, (list, tuple)):
other = [oth... | def append(self, other):
"""
Append a collection of Index options together
Parameters
----------
other : Index or list/tuple of indices
Returns
-------
appended : Index
"""
if not isinstance(other, (list, tuple)):
other = [oth... | [
"Append",
"a",
"collection",
"of",
"Index",
"options",
"together"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1828-L1859 | [
"def",
"append",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"other",
"=",
"[",
"other",
"]",
"if",
"all",
"(",
"(",
"isinstance",
"(",
"o",
",",
"MultiIndex",
")",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.drop | Make new MultiIndex with passed list of codes deleted
Parameters
----------
codes : array-like
Must be a list of tuples
level : int or level name, default None
Returns
-------
dropped : MultiIndex | pandas/core/indexes/multi.py | def drop(self, codes, level=None, errors='raise'):
"""
Make new MultiIndex with passed list of codes deleted
Parameters
----------
codes : array-like
Must be a list of tuples
level : int or level name, default None
Returns
-------
dro... | def drop(self, codes, level=None, errors='raise'):
"""
Make new MultiIndex with passed list of codes deleted
Parameters
----------
codes : array-like
Must be a list of tuples
level : int or level name, default None
Returns
-------
dro... | [
"Make",
"new",
"MultiIndex",
"with",
"passed",
"list",
"of",
"codes",
"deleted"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1878-L1933 | [
"def",
"drop",
"(",
"self",
",",
"codes",
",",
"level",
"=",
"None",
",",
"errors",
"=",
"'raise'",
")",
":",
"if",
"level",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_drop_from_level",
"(",
"codes",
",",
"level",
")",
"try",
":",
"if",
"no... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.swaplevel | Swap level i with level j.
Calling this method does not change the ordering of the values.
Parameters
----------
i : int, str, default -2
First level of index to be swapped. Can pass level name as string.
Type of parameters can be mixed.
j : int, str, de... | pandas/core/indexes/multi.py | def swaplevel(self, i=-2, j=-1):
"""
Swap level i with level j.
Calling this method does not change the ordering of the values.
Parameters
----------
i : int, str, default -2
First level of index to be swapped. Can pass level name as string.
Type... | def swaplevel(self, i=-2, j=-1):
"""
Swap level i with level j.
Calling this method does not change the ordering of the values.
Parameters
----------
i : int, str, default -2
First level of index to be swapped. Can pass level name as string.
Type... | [
"Swap",
"level",
"i",
"with",
"level",
"j",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1945-L1999 | [
"def",
"swaplevel",
"(",
"self",
",",
"i",
"=",
"-",
"2",
",",
"j",
"=",
"-",
"1",
")",
":",
"new_levels",
"=",
"list",
"(",
"self",
".",
"levels",
")",
"new_codes",
"=",
"list",
"(",
"self",
".",
"codes",
")",
"new_names",
"=",
"list",
"(",
"s... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.reorder_levels | Rearrange levels using input order. May not drop or duplicate levels
Parameters
---------- | pandas/core/indexes/multi.py | def reorder_levels(self, order):
"""
Rearrange levels using input order. May not drop or duplicate levels
Parameters
----------
"""
order = [self._get_level_number(i) for i in order]
if len(order) != self.nlevels:
raise AssertionError('Length of order... | def reorder_levels(self, order):
"""
Rearrange levels using input order. May not drop or duplicate levels
Parameters
----------
"""
order = [self._get_level_number(i) for i in order]
if len(order) != self.nlevels:
raise AssertionError('Length of order... | [
"Rearrange",
"levels",
"using",
"input",
"order",
".",
"May",
"not",
"drop",
"or",
"duplicate",
"levels"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2001-L2018 | [
"def",
"reorder_levels",
"(",
"self",
",",
"order",
")",
":",
"order",
"=",
"[",
"self",
".",
"_get_level_number",
"(",
"i",
")",
"for",
"i",
"in",
"order",
"]",
"if",
"len",
"(",
"order",
")",
"!=",
"self",
".",
"nlevels",
":",
"raise",
"AssertionEr... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex._get_codes_for_sorting | we categorizing our codes by using the
available categories (all, not just observed)
excluding any missing ones (-1); this is in preparation
for sorting, where we need to disambiguate that -1 is not
a valid valid | pandas/core/indexes/multi.py | def _get_codes_for_sorting(self):
"""
we categorizing our codes by using the
available categories (all, not just observed)
excluding any missing ones (-1); this is in preparation
for sorting, where we need to disambiguate that -1 is not
a valid valid
"""
f... | def _get_codes_for_sorting(self):
"""
we categorizing our codes by using the
available categories (all, not just observed)
excluding any missing ones (-1); this is in preparation
for sorting, where we need to disambiguate that -1 is not
a valid valid
"""
f... | [
"we",
"categorizing",
"our",
"codes",
"by",
"using",
"the",
"available",
"categories",
"(",
"all",
"not",
"just",
"observed",
")",
"excluding",
"any",
"missing",
"ones",
"(",
"-",
"1",
")",
";",
"this",
"is",
"in",
"preparation",
"for",
"sorting",
"where",... | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2023-L2040 | [
"def",
"_get_codes_for_sorting",
"(",
"self",
")",
":",
"from",
"pandas",
".",
"core",
".",
"arrays",
"import",
"Categorical",
"def",
"cats",
"(",
"level_codes",
")",
":",
"return",
"np",
".",
"arange",
"(",
"np",
".",
"array",
"(",
"level_codes",
")",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.sortlevel | Sort MultiIndex at the requested level. The result will respect the
original ordering of the associated factor at that level.
Parameters
----------
level : list-like, int or str, default 0
If a string is given, must be a name of the level
If list-like must be nam... | pandas/core/indexes/multi.py | def sortlevel(self, level=0, ascending=True, sort_remaining=True):
"""
Sort MultiIndex at the requested level. The result will respect the
original ordering of the associated factor at that level.
Parameters
----------
level : list-like, int or str, default 0
... | def sortlevel(self, level=0, ascending=True, sort_remaining=True):
"""
Sort MultiIndex at the requested level. The result will respect the
original ordering of the associated factor at that level.
Parameters
----------
level : list-like, int or str, default 0
... | [
"Sort",
"MultiIndex",
"at",
"the",
"requested",
"level",
".",
"The",
"result",
"will",
"respect",
"the",
"original",
"ordering",
"of",
"the",
"associated",
"factor",
"at",
"that",
"level",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2042-L2115 | [
"def",
"sortlevel",
"(",
"self",
",",
"level",
"=",
"0",
",",
"ascending",
"=",
"True",
",",
"sort_remaining",
"=",
"True",
")",
":",
"from",
"pandas",
".",
"core",
".",
"sorting",
"import",
"indexer_from_factorized",
"if",
"isinstance",
"(",
"level",
",",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex._convert_listlike_indexer | Parameters
----------
keyarr : list-like
Indexer to convert.
Returns
-------
tuple (indexer, keyarr)
indexer is an ndarray or None if cannot convert
keyarr are tuple-safe keys | pandas/core/indexes/multi.py | def _convert_listlike_indexer(self, keyarr, kind=None):
"""
Parameters
----------
keyarr : list-like
Indexer to convert.
Returns
-------
tuple (indexer, keyarr)
indexer is an ndarray or None if cannot convert
keyarr are tuple-s... | def _convert_listlike_indexer(self, keyarr, kind=None):
"""
Parameters
----------
keyarr : list-like
Indexer to convert.
Returns
-------
tuple (indexer, keyarr)
indexer is an ndarray or None if cannot convert
keyarr are tuple-s... | [
"Parameters",
"----------",
"keyarr",
":",
"list",
"-",
"like",
"Indexer",
"to",
"convert",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2117-L2147 | [
"def",
"_convert_listlike_indexer",
"(",
"self",
",",
"keyarr",
",",
"kind",
"=",
"None",
")",
":",
"indexer",
",",
"keyarr",
"=",
"super",
"(",
")",
".",
"_convert_listlike_indexer",
"(",
"keyarr",
",",
"kind",
"=",
"kind",
")",
"# are we indexing a specific ... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.reindex | Create index with target's values (move/add/delete values as necessary)
Returns
-------
new_index : pd.MultiIndex
Resulting index
indexer : np.ndarray or None
Indices of output values in original index. | pandas/core/indexes/multi.py | def reindex(self, target, method=None, level=None, limit=None,
tolerance=None):
"""
Create index with target's values (move/add/delete values as necessary)
Returns
-------
new_index : pd.MultiIndex
Resulting index
indexer : np.ndarray or None
... | def reindex(self, target, method=None, level=None, limit=None,
tolerance=None):
"""
Create index with target's values (move/add/delete values as necessary)
Returns
-------
new_index : pd.MultiIndex
Resulting index
indexer : np.ndarray or None
... | [
"Create",
"index",
"with",
"target",
"s",
"values",
"(",
"move",
"/",
"add",
"/",
"delete",
"values",
"as",
"necessary",
")"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2191-L2252 | [
"def",
"reindex",
"(",
"self",
",",
"target",
",",
"method",
"=",
"None",
",",
"level",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"tolerance",
"=",
"None",
")",
":",
"# GH6552: preserve names when reindexing to non-named target",
"# (i.e. neither Index nor Series... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.slice_locs | For an ordered MultiIndex, compute the slice locations for input
labels.
The input labels can be tuples representing partial levels, e.g. for a
MultiIndex with 3 levels, you can pass a single value (corresponding to
the first level), or a 1-, 2-, or 3-tuple.
Parameters
... | pandas/core/indexes/multi.py | def slice_locs(self, start=None, end=None, step=None, kind=None):
"""
For an ordered MultiIndex, compute the slice locations for input
labels.
The input labels can be tuples representing partial levels, e.g. for a
MultiIndex with 3 levels, you can pass a single value (correspond... | def slice_locs(self, start=None, end=None, step=None, kind=None):
"""
For an ordered MultiIndex, compute the slice locations for input
labels.
The input labels can be tuples representing partial levels, e.g. for a
MultiIndex with 3 levels, you can pass a single value (correspond... | [
"For",
"an",
"ordered",
"MultiIndex",
"compute",
"the",
"slice",
"locations",
"for",
"input",
"labels",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2260-L2314 | [
"def",
"slice_locs",
"(",
"self",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"step",
"=",
"None",
",",
"kind",
"=",
"None",
")",
":",
"# This function adds nothing to its parent implementation (the magic",
"# happens in get_slice_bound method), but it adds... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.get_loc | Get location for a label or a tuple of labels as an integer, slice or
boolean mask.
Parameters
----------
key : label or tuple of labels (one for each level)
method : None
Returns
-------
loc : int, slice object or boolean mask
If the key is ... | pandas/core/indexes/multi.py | def get_loc(self, key, method=None):
"""
Get location for a label or a tuple of labels as an integer, slice or
boolean mask.
Parameters
----------
key : label or tuple of labels (one for each level)
method : None
Returns
-------
loc : int... | def get_loc(self, key, method=None):
"""
Get location for a label or a tuple of labels as an integer, slice or
boolean mask.
Parameters
----------
key : label or tuple of labels (one for each level)
method : None
Returns
-------
loc : int... | [
"Get",
"location",
"for",
"a",
"label",
"or",
"a",
"tuple",
"of",
"labels",
"as",
"an",
"integer",
"slice",
"or",
"boolean",
"mask",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2347-L2445 | [
"def",
"get_loc",
"(",
"self",
",",
"key",
",",
"method",
"=",
"None",
")",
":",
"if",
"method",
"is",
"not",
"None",
":",
"raise",
"NotImplementedError",
"(",
"'only the default get_loc method is '",
"'currently supported for MultiIndex'",
")",
"def",
"_maybe_to_sl... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.get_loc_level | Get both the location for the requested label(s) and the
resulting sliced index.
Parameters
----------
key : label or sequence of labels
level : int/level name or list thereof, optional
drop_level : bool, default True
if ``False``, the resulting index will no... | pandas/core/indexes/multi.py | def get_loc_level(self, key, level=0, drop_level=True):
"""
Get both the location for the requested label(s) and the
resulting sliced index.
Parameters
----------
key : label or sequence of labels
level : int/level name or list thereof, optional
drop_leve... | def get_loc_level(self, key, level=0, drop_level=True):
"""
Get both the location for the requested label(s) and the
resulting sliced index.
Parameters
----------
key : label or sequence of labels
level : int/level name or list thereof, optional
drop_leve... | [
"Get",
"both",
"the",
"location",
"for",
"the",
"requested",
"label",
"(",
"s",
")",
"and",
"the",
"resulting",
"sliced",
"index",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2447-L2581 | [
"def",
"get_loc_level",
"(",
"self",
",",
"key",
",",
"level",
"=",
"0",
",",
"drop_level",
"=",
"True",
")",
":",
"def",
"maybe_droplevels",
"(",
"indexer",
",",
"levels",
",",
"drop_level",
")",
":",
"if",
"not",
"drop_level",
":",
"return",
"self",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.get_locs | Get location for a given label/slice/list/mask or a sequence of such as
an array of integers.
Parameters
----------
seq : label/slice/list/mask or a sequence of such
You should use one of the above for each level.
If a level should not be used, set it to ``slice(No... | pandas/core/indexes/multi.py | def get_locs(self, seq):
"""
Get location for a given label/slice/list/mask or a sequence of such as
an array of integers.
Parameters
----------
seq : label/slice/list/mask or a sequence of such
You should use one of the above for each level.
If a l... | def get_locs(self, seq):
"""
Get location for a given label/slice/list/mask or a sequence of such as
an array of integers.
Parameters
----------
seq : label/slice/list/mask or a sequence of such
You should use one of the above for each level.
If a l... | [
"Get",
"location",
"for",
"a",
"given",
"label",
"/",
"slice",
"/",
"list",
"/",
"mask",
"or",
"a",
"sequence",
"of",
"such",
"as",
"an",
"array",
"of",
"integers",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2678-L2796 | [
"def",
"get_locs",
"(",
"self",
",",
"seq",
")",
":",
"from",
".",
"numeric",
"import",
"Int64Index",
"# must be lexsorted to at least as many levels",
"true_slices",
"=",
"[",
"i",
"for",
"(",
"i",
",",
"s",
")",
"in",
"enumerate",
"(",
"com",
".",
"is_true... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.truncate | Slice index between two labels / tuples, return new MultiIndex
Parameters
----------
before : label or tuple, can be partial. Default None
None defaults to start
after : label or tuple, can be partial. Default None
None defaults to end
Returns
--... | pandas/core/indexes/multi.py | def truncate(self, before=None, after=None):
"""
Slice index between two labels / tuples, return new MultiIndex
Parameters
----------
before : label or tuple, can be partial. Default None
None defaults to start
after : label or tuple, can be partial. Default ... | def truncate(self, before=None, after=None):
"""
Slice index between two labels / tuples, return new MultiIndex
Parameters
----------
before : label or tuple, can be partial. Default None
None defaults to start
after : label or tuple, can be partial. Default ... | [
"Slice",
"index",
"between",
"two",
"labels",
"/",
"tuples",
"return",
"new",
"MultiIndex"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2798-L2826 | [
"def",
"truncate",
"(",
"self",
",",
"before",
"=",
"None",
",",
"after",
"=",
"None",
")",
":",
"if",
"after",
"and",
"before",
"and",
"after",
"<",
"before",
":",
"raise",
"ValueError",
"(",
"'after < before'",
")",
"i",
",",
"j",
"=",
"self",
".",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.equals | Determines if two MultiIndex objects have the same labeling information
(the levels themselves do not necessarily have to be the same)
See Also
--------
equal_levels | pandas/core/indexes/multi.py | def equals(self, other):
"""
Determines if two MultiIndex objects have the same labeling information
(the levels themselves do not necessarily have to be the same)
See Also
--------
equal_levels
"""
if self.is_(other):
return True
if ... | def equals(self, other):
"""
Determines if two MultiIndex objects have the same labeling information
(the levels themselves do not necessarily have to be the same)
See Also
--------
equal_levels
"""
if self.is_(other):
return True
if ... | [
"Determines",
"if",
"two",
"MultiIndex",
"objects",
"have",
"the",
"same",
"labeling",
"information",
"(",
"the",
"levels",
"themselves",
"do",
"not",
"necessarily",
"have",
"to",
"be",
"the",
"same",
")"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2828-L2876 | [
"def",
"equals",
"(",
"self",
",",
"other",
")",
":",
"if",
"self",
".",
"is_",
"(",
"other",
")",
":",
"return",
"True",
"if",
"not",
"isinstance",
"(",
"other",
",",
"Index",
")",
":",
"return",
"False",
"if",
"not",
"isinstance",
"(",
"other",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.equal_levels | Return True if the levels of both MultiIndex objects are the same | pandas/core/indexes/multi.py | def equal_levels(self, other):
"""
Return True if the levels of both MultiIndex objects are the same
"""
if self.nlevels != other.nlevels:
return False
for i in range(self.nlevels):
if not self.levels[i].equals(other.levels[i]):
return Fa... | def equal_levels(self, other):
"""
Return True if the levels of both MultiIndex objects are the same
"""
if self.nlevels != other.nlevels:
return False
for i in range(self.nlevels):
if not self.levels[i].equals(other.levels[i]):
return Fa... | [
"Return",
"True",
"if",
"the",
"levels",
"of",
"both",
"MultiIndex",
"objects",
"are",
"the",
"same"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2878-L2889 | [
"def",
"equal_levels",
"(",
"self",
",",
"other",
")",
":",
"if",
"self",
".",
"nlevels",
"!=",
"other",
".",
"nlevels",
":",
"return",
"False",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"nlevels",
")",
":",
"if",
"not",
"self",
".",
"levels",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.union | Form the union of two MultiIndex objects
Parameters
----------
other : MultiIndex or array / Index of tuples
sort : False or None, default None
Whether to sort the resulting Index.
* None : Sort the result, except when
1. `self` and `other` are eq... | pandas/core/indexes/multi.py | def union(self, other, sort=None):
"""
Form the union of two MultiIndex objects
Parameters
----------
other : MultiIndex or array / Index of tuples
sort : False or None, default None
Whether to sort the resulting Index.
* None : Sort the result, ... | def union(self, other, sort=None):
"""
Form the union of two MultiIndex objects
Parameters
----------
other : MultiIndex or array / Index of tuples
sort : False or None, default None
Whether to sort the resulting Index.
* None : Sort the result, ... | [
"Form",
"the",
"union",
"of",
"two",
"MultiIndex",
"objects"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2891-L2937 | [
"def",
"union",
"(",
"self",
",",
"other",
",",
"sort",
"=",
"None",
")",
":",
"self",
".",
"_validate_sort_keyword",
"(",
"sort",
")",
"self",
".",
"_assert_can_do_setop",
"(",
"other",
")",
"other",
",",
"result_names",
"=",
"self",
".",
"_convert_can_do... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.intersection | Form the intersection of two MultiIndex objects.
Parameters
----------
other : MultiIndex or array / Index of tuples
sort : False or None, default False
Sort the resulting MultiIndex if possible
.. versionadded:: 0.24.0
.. versionchanged:: 0.24.1
... | pandas/core/indexes/multi.py | def intersection(self, other, sort=False):
"""
Form the intersection of two MultiIndex objects.
Parameters
----------
other : MultiIndex or array / Index of tuples
sort : False or None, default False
Sort the resulting MultiIndex if possible
.. v... | def intersection(self, other, sort=False):
"""
Form the intersection of two MultiIndex objects.
Parameters
----------
other : MultiIndex or array / Index of tuples
sort : False or None, default False
Sort the resulting MultiIndex if possible
.. v... | [
"Form",
"the",
"intersection",
"of",
"two",
"MultiIndex",
"objects",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2939-L2980 | [
"def",
"intersection",
"(",
"self",
",",
"other",
",",
"sort",
"=",
"False",
")",
":",
"self",
".",
"_validate_sort_keyword",
"(",
"sort",
")",
"self",
".",
"_assert_can_do_setop",
"(",
"other",
")",
"other",
",",
"result_names",
"=",
"self",
".",
"_conver... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.difference | Compute set difference of two MultiIndex objects
Parameters
----------
other : MultiIndex
sort : False or None, default None
Sort the resulting MultiIndex if possible
.. versionadded:: 0.24.0
.. versionchanged:: 0.24.1
Changed the de... | pandas/core/indexes/multi.py | def difference(self, other, sort=None):
"""
Compute set difference of two MultiIndex objects
Parameters
----------
other : MultiIndex
sort : False or None, default None
Sort the resulting MultiIndex if possible
.. versionadded:: 0.24.0
... | def difference(self, other, sort=None):
"""
Compute set difference of two MultiIndex objects
Parameters
----------
other : MultiIndex
sort : False or None, default None
Sort the resulting MultiIndex if possible
.. versionadded:: 0.24.0
... | [
"Compute",
"set",
"difference",
"of",
"two",
"MultiIndex",
"objects"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2982-L3032 | [
"def",
"difference",
"(",
"self",
",",
"other",
",",
"sort",
"=",
"None",
")",
":",
"self",
".",
"_validate_sort_keyword",
"(",
"sort",
")",
"self",
".",
"_assert_can_do_setop",
"(",
"other",
")",
"other",
",",
"result_names",
"=",
"self",
".",
"_convert_c... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.insert | Make new MultiIndex inserting new item at location
Parameters
----------
loc : int
item : tuple
Must be same length as number of levels in the MultiIndex
Returns
-------
new_index : Index | pandas/core/indexes/multi.py | def insert(self, loc, item):
"""
Make new MultiIndex inserting new item at location
Parameters
----------
loc : int
item : tuple
Must be same length as number of levels in the MultiIndex
Returns
-------
new_index : Index
"""
... | def insert(self, loc, item):
"""
Make new MultiIndex inserting new item at location
Parameters
----------
loc : int
item : tuple
Must be same length as number of levels in the MultiIndex
Returns
-------
new_index : Index
"""
... | [
"Make",
"new",
"MultiIndex",
"inserting",
"new",
"item",
"at",
"location"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L3066-L3105 | [
"def",
"insert",
"(",
"self",
",",
"loc",
",",
"item",
")",
":",
"# Pad the key with empty strings if lower levels of the key",
"# aren't specified:",
"if",
"not",
"isinstance",
"(",
"item",
",",
"tuple",
")",
":",
"item",
"=",
"(",
"item",
",",
")",
"+",
"(",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | MultiIndex.delete | Make new index with passed location deleted
Returns
-------
new_index : MultiIndex | pandas/core/indexes/multi.py | def delete(self, loc):
"""
Make new index with passed location deleted
Returns
-------
new_index : MultiIndex
"""
new_codes = [np.delete(level_codes, loc) for level_codes in self.codes]
return MultiIndex(levels=self.levels, codes=new_codes,
... | def delete(self, loc):
"""
Make new index with passed location deleted
Returns
-------
new_index : MultiIndex
"""
new_codes = [np.delete(level_codes, loc) for level_codes in self.codes]
return MultiIndex(levels=self.levels, codes=new_codes,
... | [
"Make",
"new",
"index",
"with",
"passed",
"location",
"deleted"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L3107-L3117 | [
"def",
"delete",
"(",
"self",
",",
"loc",
")",
":",
"new_codes",
"=",
"[",
"np",
".",
"delete",
"(",
"level_codes",
",",
"loc",
")",
"for",
"level_codes",
"in",
"self",
".",
"codes",
"]",
"return",
"MultiIndex",
"(",
"levels",
"=",
"self",
".",
"leve... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _ensure_data | routine to ensure that our data is of the correct
input dtype for lower-level routines
This will coerce:
- ints -> int64
- uint -> uint64
- bool -> uint64 (TODO this should be uint8)
- datetimelike -> i8
- datetime64tz -> i8 (in local tz)
- categorical -> codes
Parameters
-----... | pandas/core/algorithms.py | def _ensure_data(values, dtype=None):
"""
routine to ensure that our data is of the correct
input dtype for lower-level routines
This will coerce:
- ints -> int64
- uint -> uint64
- bool -> uint64 (TODO this should be uint8)
- datetimelike -> i8
- datetime64tz -> i8 (in local tz)
... | def _ensure_data(values, dtype=None):
"""
routine to ensure that our data is of the correct
input dtype for lower-level routines
This will coerce:
- ints -> int64
- uint -> uint64
- bool -> uint64 (TODO this should be uint8)
- datetimelike -> i8
- datetime64tz -> i8 (in local tz)
... | [
"routine",
"to",
"ensure",
"that",
"our",
"data",
"is",
"of",
"the",
"correct",
"input",
"dtype",
"for",
"lower",
"-",
"level",
"routines"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L36-L127 | [
"def",
"_ensure_data",
"(",
"values",
",",
"dtype",
"=",
"None",
")",
":",
"# we check some simple dtypes first",
"try",
":",
"if",
"is_object_dtype",
"(",
"dtype",
")",
":",
"return",
"ensure_object",
"(",
"np",
".",
"asarray",
"(",
"values",
")",
")",
",",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _reconstruct_data | reverse of _ensure_data
Parameters
----------
values : ndarray
dtype : pandas_dtype
original : ndarray-like
Returns
-------
Index for extension types, otherwise ndarray casted to dtype | pandas/core/algorithms.py | def _reconstruct_data(values, dtype, original):
"""
reverse of _ensure_data
Parameters
----------
values : ndarray
dtype : pandas_dtype
original : ndarray-like
Returns
-------
Index for extension types, otherwise ndarray casted to dtype
"""
from pandas import Index
... | def _reconstruct_data(values, dtype, original):
"""
reverse of _ensure_data
Parameters
----------
values : ndarray
dtype : pandas_dtype
original : ndarray-like
Returns
-------
Index for extension types, otherwise ndarray casted to dtype
"""
from pandas import Index
... | [
"reverse",
"of",
"_ensure_data"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L130-L158 | [
"def",
"_reconstruct_data",
"(",
"values",
",",
"dtype",
",",
"original",
")",
":",
"from",
"pandas",
"import",
"Index",
"if",
"is_extension_array_dtype",
"(",
"dtype",
")",
":",
"values",
"=",
"dtype",
".",
"construct_array_type",
"(",
")",
".",
"_from_sequen... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _ensure_arraylike | ensure that we are arraylike if not already | pandas/core/algorithms.py | def _ensure_arraylike(values):
"""
ensure that we are arraylike if not already
"""
if not is_array_like(values):
inferred = lib.infer_dtype(values, skipna=False)
if inferred in ['mixed', 'string', 'unicode']:
if isinstance(values, tuple):
values = list(values)... | def _ensure_arraylike(values):
"""
ensure that we are arraylike if not already
"""
if not is_array_like(values):
inferred = lib.infer_dtype(values, skipna=False)
if inferred in ['mixed', 'string', 'unicode']:
if isinstance(values, tuple):
values = list(values)... | [
"ensure",
"that",
"we",
"are",
"arraylike",
"if",
"not",
"already"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L161-L173 | [
"def",
"_ensure_arraylike",
"(",
"values",
")",
":",
"if",
"not",
"is_array_like",
"(",
"values",
")",
":",
"inferred",
"=",
"lib",
".",
"infer_dtype",
"(",
"values",
",",
"skipna",
"=",
"False",
")",
"if",
"inferred",
"in",
"[",
"'mixed'",
",",
"'string... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _get_hashtable_algo | Parameters
----------
values : arraylike
Returns
-------
tuples(hashtable class,
vector class,
values,
dtype,
ndtype) | pandas/core/algorithms.py | def _get_hashtable_algo(values):
"""
Parameters
----------
values : arraylike
Returns
-------
tuples(hashtable class,
vector class,
values,
dtype,
ndtype)
"""
values, dtype, ndtype = _ensure_data(values)
if ndtype == 'object':
... | def _get_hashtable_algo(values):
"""
Parameters
----------
values : arraylike
Returns
-------
tuples(hashtable class,
vector class,
values,
dtype,
ndtype)
"""
values, dtype, ndtype = _ensure_data(values)
if ndtype == 'object':
... | [
"Parameters",
"----------",
"values",
":",
"arraylike"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L185-L212 | [
"def",
"_get_hashtable_algo",
"(",
"values",
")",
":",
"values",
",",
"dtype",
",",
"ndtype",
"=",
"_ensure_data",
"(",
"values",
")",
"if",
"ndtype",
"==",
"'object'",
":",
"# it's cheaper to use a String Hash Table than Object; we infer",
"# including nulls because that... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | match | Compute locations of to_match into values
Parameters
----------
to_match : array-like
values to find positions of
values : array-like
Unique set of values
na_sentinel : int, default -1
Value to mark "not found"
Examples
--------
Returns
-------
match : ... | pandas/core/algorithms.py | def match(to_match, values, na_sentinel=-1):
"""
Compute locations of to_match into values
Parameters
----------
to_match : array-like
values to find positions of
values : array-like
Unique set of values
na_sentinel : int, default -1
Value to mark "not found"
Ex... | def match(to_match, values, na_sentinel=-1):
"""
Compute locations of to_match into values
Parameters
----------
to_match : array-like
values to find positions of
values : array-like
Unique set of values
na_sentinel : int, default -1
Value to mark "not found"
Ex... | [
"Compute",
"locations",
"of",
"to_match",
"into",
"values"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L238-L273 | [
"def",
"match",
"(",
"to_match",
",",
"values",
",",
"na_sentinel",
"=",
"-",
"1",
")",
":",
"values",
"=",
"com",
".",
"asarray_tuplesafe",
"(",
"values",
")",
"htable",
",",
"_",
",",
"values",
",",
"dtype",
",",
"ndtype",
"=",
"_get_hashtable_algo",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | unique | Hash table-based unique. Uniques are returned in order
of appearance. This does NOT sort.
Significantly faster than numpy.unique. Includes NA values.
Parameters
----------
values : 1d array-like
Returns
-------
numpy.ndarray or ExtensionArray
The return can be:
* Ind... | pandas/core/algorithms.py | def unique(values):
"""
Hash table-based unique. Uniques are returned in order
of appearance. This does NOT sort.
Significantly faster than numpy.unique. Includes NA values.
Parameters
----------
values : 1d array-like
Returns
-------
numpy.ndarray or ExtensionArray
T... | def unique(values):
"""
Hash table-based unique. Uniques are returned in order
of appearance. This does NOT sort.
Significantly faster than numpy.unique. Includes NA values.
Parameters
----------
values : 1d array-like
Returns
-------
numpy.ndarray or ExtensionArray
T... | [
"Hash",
"table",
"-",
"based",
"unique",
".",
"Uniques",
"are",
"returned",
"in",
"order",
"of",
"appearance",
".",
"This",
"does",
"NOT",
"sort",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L276-L367 | [
"def",
"unique",
"(",
"values",
")",
":",
"values",
"=",
"_ensure_arraylike",
"(",
"values",
")",
"if",
"is_extension_array_dtype",
"(",
"values",
")",
":",
"# Dispatch to extension dtype's unique.",
"return",
"values",
".",
"unique",
"(",
")",
"original",
"=",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | isin | Compute the isin boolean array
Parameters
----------
comps : array-like
values : array-like
Returns
-------
boolean array same length as comps | pandas/core/algorithms.py | def isin(comps, values):
"""
Compute the isin boolean array
Parameters
----------
comps : array-like
values : array-like
Returns
-------
boolean array same length as comps
"""
if not is_list_like(comps):
raise TypeError("only list-like objects are allowed to be pas... | def isin(comps, values):
"""
Compute the isin boolean array
Parameters
----------
comps : array-like
values : array-like
Returns
-------
boolean array same length as comps
"""
if not is_list_like(comps):
raise TypeError("only list-like objects are allowed to be pas... | [
"Compute",
"the",
"isin",
"boolean",
"array"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L373-L434 | [
"def",
"isin",
"(",
"comps",
",",
"values",
")",
":",
"if",
"not",
"is_list_like",
"(",
"comps",
")",
":",
"raise",
"TypeError",
"(",
"\"only list-like objects are allowed to be passed\"",
"\" to isin(), you passed a [{comps_type}]\"",
".",
"format",
"(",
"comps_type",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _factorize_array | Factorize an array-like to labels and uniques.
This doesn't do any coercion of types or unboxing before factorization.
Parameters
----------
values : ndarray
na_sentinel : int, default -1
size_hint : int, optional
Passsed through to the hashtable's 'get_labels' method
na_value : ob... | pandas/core/algorithms.py | def _factorize_array(values, na_sentinel=-1, size_hint=None,
na_value=None):
"""Factorize an array-like to labels and uniques.
This doesn't do any coercion of types or unboxing before factorization.
Parameters
----------
values : ndarray
na_sentinel : int, default -1
s... | def _factorize_array(values, na_sentinel=-1, size_hint=None,
na_value=None):
"""Factorize an array-like to labels and uniques.
This doesn't do any coercion of types or unboxing before factorization.
Parameters
----------
values : ndarray
na_sentinel : int, default -1
s... | [
"Factorize",
"an",
"array",
"-",
"like",
"to",
"labels",
"and",
"uniques",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L437-L466 | [
"def",
"_factorize_array",
"(",
"values",
",",
"na_sentinel",
"=",
"-",
"1",
",",
"size_hint",
"=",
"None",
",",
"na_value",
"=",
"None",
")",
":",
"(",
"hash_klass",
",",
"_",
")",
",",
"values",
"=",
"_get_data_algo",
"(",
"values",
",",
"_hashtables",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | value_counts | Compute a histogram of the counts of non-null values.
Parameters
----------
values : ndarray (1-d)
sort : boolean, default True
Sort by values
ascending : boolean, default False
Sort in ascending order
normalize: boolean, default False
If True then compute a relative his... | pandas/core/algorithms.py | def value_counts(values, sort=True, ascending=False, normalize=False,
bins=None, dropna=True):
"""
Compute a histogram of the counts of non-null values.
Parameters
----------
values : ndarray (1-d)
sort : boolean, default True
Sort by values
ascending : boolean, def... | def value_counts(values, sort=True, ascending=False, normalize=False,
bins=None, dropna=True):
"""
Compute a histogram of the counts of non-null values.
Parameters
----------
values : ndarray (1-d)
sort : boolean, default True
Sort by values
ascending : boolean, def... | [
"Compute",
"a",
"histogram",
"of",
"the",
"counts",
"of",
"non",
"-",
"null",
"values",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L649-L720 | [
"def",
"value_counts",
"(",
"values",
",",
"sort",
"=",
"True",
",",
"ascending",
"=",
"False",
",",
"normalize",
"=",
"False",
",",
"bins",
"=",
"None",
",",
"dropna",
"=",
"True",
")",
":",
"from",
"pandas",
".",
"core",
".",
"series",
"import",
"S... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _value_counts_arraylike | Parameters
----------
values : arraylike
dropna : boolean
Returns
-------
(uniques, counts) | pandas/core/algorithms.py | def _value_counts_arraylike(values, dropna):
"""
Parameters
----------
values : arraylike
dropna : boolean
Returns
-------
(uniques, counts)
"""
values = _ensure_arraylike(values)
original = values
values, dtype, ndtype = _ensure_data(values)
if needs_i8_conversion... | def _value_counts_arraylike(values, dropna):
"""
Parameters
----------
values : arraylike
dropna : boolean
Returns
-------
(uniques, counts)
"""
values = _ensure_arraylike(values)
original = values
values, dtype, ndtype = _ensure_data(values)
if needs_i8_conversion... | [
"Parameters",
"----------",
"values",
":",
"arraylike",
"dropna",
":",
"boolean"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L723-L763 | [
"def",
"_value_counts_arraylike",
"(",
"values",
",",
"dropna",
")",
":",
"values",
"=",
"_ensure_arraylike",
"(",
"values",
")",
"original",
"=",
"values",
"values",
",",
"dtype",
",",
"ndtype",
"=",
"_ensure_data",
"(",
"values",
")",
"if",
"needs_i8_convers... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | duplicated | Return boolean ndarray denoting duplicate values.
.. versionadded:: 0.19.0
Parameters
----------
values : ndarray-like
Array over which to check for duplicate values.
keep : {'first', 'last', False}, default 'first'
- ``first`` : Mark duplicates as ``True`` except for the first
... | pandas/core/algorithms.py | def duplicated(values, keep='first'):
"""
Return boolean ndarray denoting duplicate values.
.. versionadded:: 0.19.0
Parameters
----------
values : ndarray-like
Array over which to check for duplicate values.
keep : {'first', 'last', False}, default 'first'
- ``first`` : Ma... | def duplicated(values, keep='first'):
"""
Return boolean ndarray denoting duplicate values.
.. versionadded:: 0.19.0
Parameters
----------
values : ndarray-like
Array over which to check for duplicate values.
keep : {'first', 'last', False}, default 'first'
- ``first`` : Ma... | [
"Return",
"boolean",
"ndarray",
"denoting",
"duplicate",
"values",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L766-L790 | [
"def",
"duplicated",
"(",
"values",
",",
"keep",
"=",
"'first'",
")",
":",
"values",
",",
"dtype",
",",
"ndtype",
"=",
"_ensure_data",
"(",
"values",
")",
"f",
"=",
"getattr",
"(",
"htable",
",",
"\"duplicated_{dtype}\"",
".",
"format",
"(",
"dtype",
"="... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | mode | Returns the mode(s) of an array.
Parameters
----------
values : array-like
Array over which to check for duplicate values.
dropna : boolean, default True
Don't consider counts of NaN/NaT.
.. versionadded:: 0.24.0
Returns
-------
mode : Series | pandas/core/algorithms.py | def mode(values, dropna=True):
"""
Returns the mode(s) of an array.
Parameters
----------
values : array-like
Array over which to check for duplicate values.
dropna : boolean, default True
Don't consider counts of NaN/NaT.
.. versionadded:: 0.24.0
Returns
-----... | def mode(values, dropna=True):
"""
Returns the mode(s) of an array.
Parameters
----------
values : array-like
Array over which to check for duplicate values.
dropna : boolean, default True
Don't consider counts of NaN/NaT.
.. versionadded:: 0.24.0
Returns
-----... | [
"Returns",
"the",
"mode",
"(",
"s",
")",
"of",
"an",
"array",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L793-L835 | [
"def",
"mode",
"(",
"values",
",",
"dropna",
"=",
"True",
")",
":",
"from",
"pandas",
"import",
"Series",
"values",
"=",
"_ensure_arraylike",
"(",
"values",
")",
"original",
"=",
"values",
"# categorical is a fast-path",
"if",
"is_categorical_dtype",
"(",
"value... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | rank | Rank the values along a given axis.
Parameters
----------
values : array-like
Array whose values will be ranked. The number of dimensions in this
array must not exceed 2.
axis : int, default 0
Axis over which to perform rankings.
method : {'average', 'min', 'max', 'first', '... | pandas/core/algorithms.py | def rank(values, axis=0, method='average', na_option='keep',
ascending=True, pct=False):
"""
Rank the values along a given axis.
Parameters
----------
values : array-like
Array whose values will be ranked. The number of dimensions in this
array must not exceed 2.
axis :... | def rank(values, axis=0, method='average', na_option='keep',
ascending=True, pct=False):
"""
Rank the values along a given axis.
Parameters
----------
values : array-like
Array whose values will be ranked. The number of dimensions in this
array must not exceed 2.
axis :... | [
"Rank",
"the",
"values",
"along",
"a",
"given",
"axis",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L838-L874 | [
"def",
"rank",
"(",
"values",
",",
"axis",
"=",
"0",
",",
"method",
"=",
"'average'",
",",
"na_option",
"=",
"'keep'",
",",
"ascending",
"=",
"True",
",",
"pct",
"=",
"False",
")",
":",
"if",
"values",
".",
"ndim",
"==",
"1",
":",
"f",
",",
"valu... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | checked_add_with_arr | Perform array addition that checks for underflow and overflow.
Performs the addition of an int64 array and an int64 integer (or array)
but checks that they do not result in overflow first. For elements that
are indicated to be NaN, whether or not there is overflow for that element
is automatically igno... | pandas/core/algorithms.py | def checked_add_with_arr(arr, b, arr_mask=None, b_mask=None):
"""
Perform array addition that checks for underflow and overflow.
Performs the addition of an int64 array and an int64 integer (or array)
but checks that they do not result in overflow first. For elements that
are indicated to be NaN, w... | def checked_add_with_arr(arr, b, arr_mask=None, b_mask=None):
"""
Perform array addition that checks for underflow and overflow.
Performs the addition of an int64 array and an int64 integer (or array)
but checks that they do not result in overflow first. For elements that
are indicated to be NaN, w... | [
"Perform",
"array",
"addition",
"that",
"checks",
"for",
"underflow",
"and",
"overflow",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L877-L948 | [
"def",
"checked_add_with_arr",
"(",
"arr",
",",
"b",
",",
"arr_mask",
"=",
"None",
",",
"b_mask",
"=",
"None",
")",
":",
"# For performance reasons, we broadcast 'b' to the new array 'b2'",
"# so that it has the same size as 'arr'.",
"b2",
"=",
"np",
".",
"broadcast_to",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | quantile | Compute sample quantile or quantiles of the input array. For example, q=0.5
computes the median.
The `interpolation_method` parameter supports three values, namely
`fraction` (default), `lower` and `higher`. Interpolation is done only,
if the desired quantile lies between two data points `i` and `j`. F... | pandas/core/algorithms.py | def quantile(x, q, interpolation_method='fraction'):
"""
Compute sample quantile or quantiles of the input array. For example, q=0.5
computes the median.
The `interpolation_method` parameter supports three values, namely
`fraction` (default), `lower` and `higher`. Interpolation is done only,
if... | def quantile(x, q, interpolation_method='fraction'):
"""
Compute sample quantile or quantiles of the input array. For example, q=0.5
computes the median.
The `interpolation_method` parameter supports three values, namely
`fraction` (default), `lower` and `higher`. Interpolation is done only,
if... | [
"Compute",
"sample",
"quantile",
"or",
"quantiles",
"of",
"the",
"input",
"array",
".",
"For",
"example",
"q",
"=",
"0",
".",
"5",
"computes",
"the",
"median",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L966-L1043 | [
"def",
"quantile",
"(",
"x",
",",
"q",
",",
"interpolation_method",
"=",
"'fraction'",
")",
":",
"x",
"=",
"np",
".",
"asarray",
"(",
"x",
")",
"mask",
"=",
"isna",
"(",
"x",
")",
"x",
"=",
"x",
"[",
"~",
"mask",
"]",
"values",
"=",
"np",
".",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | take | Take elements from an array.
.. versionadded:: 0.23.0
Parameters
----------
arr : sequence
Non array-likes (sequences without a dtype) are coerced
to an ndarray.
indices : sequence of integers
Indices to be taken.
axis : int, default 0
The axis over which to sel... | pandas/core/algorithms.py | def take(arr, indices, axis=0, allow_fill=False, fill_value=None):
"""
Take elements from an array.
.. versionadded:: 0.23.0
Parameters
----------
arr : sequence
Non array-likes (sequences without a dtype) are coerced
to an ndarray.
indices : sequence of integers
In... | def take(arr, indices, axis=0, allow_fill=False, fill_value=None):
"""
Take elements from an array.
.. versionadded:: 0.23.0
Parameters
----------
arr : sequence
Non array-likes (sequences without a dtype) are coerced
to an ndarray.
indices : sequence of integers
In... | [
"Take",
"elements",
"from",
"an",
"array",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L1457-L1548 | [
"def",
"take",
"(",
"arr",
",",
"indices",
",",
"axis",
"=",
"0",
",",
"allow_fill",
"=",
"False",
",",
"fill_value",
"=",
"None",
")",
":",
"from",
"pandas",
".",
"core",
".",
"indexing",
"import",
"validate_indices",
"if",
"not",
"is_array_like",
"(",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | take_nd | Specialized Cython take which sets NaN values in one pass
This dispatches to ``take`` defined on ExtensionArrays. It does not
currently dispatch to ``SparseArray.take`` for sparse ``arr``.
Parameters
----------
arr : array-like
Input array.
indexer : ndarray
1-D array of indice... | pandas/core/algorithms.py | def take_nd(arr, indexer, axis=0, out=None, fill_value=np.nan, mask_info=None,
allow_fill=True):
"""
Specialized Cython take which sets NaN values in one pass
This dispatches to ``take`` defined on ExtensionArrays. It does not
currently dispatch to ``SparseArray.take`` for sparse ``arr``.
... | def take_nd(arr, indexer, axis=0, out=None, fill_value=np.nan, mask_info=None,
allow_fill=True):
"""
Specialized Cython take which sets NaN values in one pass
This dispatches to ``take`` defined on ExtensionArrays. It does not
currently dispatch to ``SparseArray.take`` for sparse ``arr``.
... | [
"Specialized",
"Cython",
"take",
"which",
"sets",
"NaN",
"values",
"in",
"one",
"pass"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L1551-L1666 | [
"def",
"take_nd",
"(",
"arr",
",",
"indexer",
",",
"axis",
"=",
"0",
",",
"out",
"=",
"None",
",",
"fill_value",
"=",
"np",
".",
"nan",
",",
"mask_info",
"=",
"None",
",",
"allow_fill",
"=",
"True",
")",
":",
"# TODO(EA): Remove these if / elifs as datetim... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | take_2d_multi | Specialized Cython take which sets NaN values in one pass | pandas/core/algorithms.py | def take_2d_multi(arr, indexer, out=None, fill_value=np.nan, mask_info=None,
allow_fill=True):
"""
Specialized Cython take which sets NaN values in one pass
"""
if indexer is None or (indexer[0] is None and indexer[1] is None):
row_idx = np.arange(arr.shape[0], dtype=np.int64)
... | def take_2d_multi(arr, indexer, out=None, fill_value=np.nan, mask_info=None,
allow_fill=True):
"""
Specialized Cython take which sets NaN values in one pass
"""
if indexer is None or (indexer[0] is None and indexer[1] is None):
row_idx = np.arange(arr.shape[0], dtype=np.int64)
... | [
"Specialized",
"Cython",
"take",
"which",
"sets",
"NaN",
"values",
"in",
"one",
"pass"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L1672-L1737 | [
"def",
"take_2d_multi",
"(",
"arr",
",",
"indexer",
",",
"out",
"=",
"None",
",",
"fill_value",
"=",
"np",
".",
"nan",
",",
"mask_info",
"=",
"None",
",",
"allow_fill",
"=",
"True",
")",
":",
"if",
"indexer",
"is",
"None",
"or",
"(",
"indexer",
"[",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | searchsorted | Find indices where elements should be inserted to maintain order.
.. versionadded:: 0.25.0
Find the indices into a sorted array `arr` (a) such that, if the
corresponding elements in `value` were inserted before the indices,
the order of `arr` would be preserved.
Assuming that `arr` is sorted:
... | pandas/core/algorithms.py | def searchsorted(arr, value, side="left", sorter=None):
"""
Find indices where elements should be inserted to maintain order.
.. versionadded:: 0.25.0
Find the indices into a sorted array `arr` (a) such that, if the
corresponding elements in `value` were inserted before the indices,
the order ... | def searchsorted(arr, value, side="left", sorter=None):
"""
Find indices where elements should be inserted to maintain order.
.. versionadded:: 0.25.0
Find the indices into a sorted array `arr` (a) such that, if the
corresponding elements in `value` were inserted before the indices,
the order ... | [
"Find",
"indices",
"where",
"elements",
"should",
"be",
"inserted",
"to",
"maintain",
"order",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L1744-L1820 | [
"def",
"searchsorted",
"(",
"arr",
",",
"value",
",",
"side",
"=",
"\"left\"",
",",
"sorter",
"=",
"None",
")",
":",
"if",
"sorter",
"is",
"not",
"None",
":",
"sorter",
"=",
"ensure_platform_int",
"(",
"sorter",
")",
"if",
"isinstance",
"(",
"arr",
","... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | diff | difference of n between self,
analogous to s-s.shift(n)
Parameters
----------
arr : ndarray
n : int
number of periods
axis : int
axis to shift on
Returns
-------
shifted | pandas/core/algorithms.py | def diff(arr, n, axis=0):
"""
difference of n between self,
analogous to s-s.shift(n)
Parameters
----------
arr : ndarray
n : int
number of periods
axis : int
axis to shift on
Returns
-------
shifted
"""
n = int(n)
na = np.nan
dtype = arr.d... | def diff(arr, n, axis=0):
"""
difference of n between self,
analogous to s-s.shift(n)
Parameters
----------
arr : ndarray
n : int
number of periods
axis : int
axis to shift on
Returns
-------
shifted
"""
n = int(n)
na = np.nan
dtype = arr.d... | [
"difference",
"of",
"n",
"between",
"self",
"analogous",
"to",
"s",
"-",
"s",
".",
"shift",
"(",
"n",
")"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L1837-L1916 | [
"def",
"diff",
"(",
"arr",
",",
"n",
",",
"axis",
"=",
"0",
")",
":",
"n",
"=",
"int",
"(",
"n",
")",
"na",
"=",
"np",
".",
"nan",
"dtype",
"=",
"arr",
".",
"dtype",
"is_timedelta",
"=",
"False",
"if",
"needs_i8_conversion",
"(",
"arr",
")",
":... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _to_ijv | For arbitrary (MultiIndexed) SparseSeries return
(v, i, j, ilabels, jlabels) where (v, (i, j)) is suitable for
passing to scipy.sparse.coo constructor. | pandas/core/sparse/scipy_sparse.py | def _to_ijv(ss, row_levels=(0, ), column_levels=(1, ), sort_labels=False):
""" For arbitrary (MultiIndexed) SparseSeries return
(v, i, j, ilabels, jlabels) where (v, (i, j)) is suitable for
passing to scipy.sparse.coo constructor. """
# index and column levels must be a partition of the index
_check... | def _to_ijv(ss, row_levels=(0, ), column_levels=(1, ), sort_labels=False):
""" For arbitrary (MultiIndexed) SparseSeries return
(v, i, j, ilabels, jlabels) where (v, (i, j)) is suitable for
passing to scipy.sparse.coo constructor. """
# index and column levels must be a partition of the index
_check... | [
"For",
"arbitrary",
"(",
"MultiIndexed",
")",
"SparseSeries",
"return",
"(",
"v",
"i",
"j",
"ilabels",
"jlabels",
")",
"where",
"(",
"v",
"(",
"i",
"j",
"))",
"is",
"suitable",
"for",
"passing",
"to",
"scipy",
".",
"sparse",
".",
"coo",
"constructor",
... | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/scipy_sparse.py#L24-L90 | [
"def",
"_to_ijv",
"(",
"ss",
",",
"row_levels",
"=",
"(",
"0",
",",
")",
",",
"column_levels",
"=",
"(",
"1",
",",
")",
",",
"sort_labels",
"=",
"False",
")",
":",
"# index and column levels must be a partition of the index",
"_check_is_partition",
"(",
"[",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _sparse_series_to_coo | Convert a SparseSeries to a scipy.sparse.coo_matrix using index
levels row_levels, column_levels as the row and column
labels respectively. Returns the sparse_matrix, row and column labels. | pandas/core/sparse/scipy_sparse.py | def _sparse_series_to_coo(ss, row_levels=(0, ), column_levels=(1, ),
sort_labels=False):
"""
Convert a SparseSeries to a scipy.sparse.coo_matrix using index
levels row_levels, column_levels as the row and column
labels respectively. Returns the sparse_matrix, row and column lab... | def _sparse_series_to_coo(ss, row_levels=(0, ), column_levels=(1, ),
sort_labels=False):
"""
Convert a SparseSeries to a scipy.sparse.coo_matrix using index
levels row_levels, column_levels as the row and column
labels respectively. Returns the sparse_matrix, row and column lab... | [
"Convert",
"a",
"SparseSeries",
"to",
"a",
"scipy",
".",
"sparse",
".",
"coo_matrix",
"using",
"index",
"levels",
"row_levels",
"column_levels",
"as",
"the",
"row",
"and",
"column",
"labels",
"respectively",
".",
"Returns",
"the",
"sparse_matrix",
"row",
"and",
... | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/scipy_sparse.py#L93-L118 | [
"def",
"_sparse_series_to_coo",
"(",
"ss",
",",
"row_levels",
"=",
"(",
"0",
",",
")",
",",
"column_levels",
"=",
"(",
"1",
",",
")",
",",
"sort_labels",
"=",
"False",
")",
":",
"import",
"scipy",
".",
"sparse",
"if",
"ss",
".",
"index",
".",
"nlevel... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _coo_to_sparse_series | Convert a scipy.sparse.coo_matrix to a SparseSeries.
Use the defaults given in the SparseSeries constructor. | pandas/core/sparse/scipy_sparse.py | def _coo_to_sparse_series(A, dense_index=False):
"""
Convert a scipy.sparse.coo_matrix to a SparseSeries.
Use the defaults given in the SparseSeries constructor.
"""
s = Series(A.data, MultiIndex.from_arrays((A.row, A.col)))
s = s.sort_index()
s = s.to_sparse() # TODO: specify kind?
if ... | def _coo_to_sparse_series(A, dense_index=False):
"""
Convert a scipy.sparse.coo_matrix to a SparseSeries.
Use the defaults given in the SparseSeries constructor.
"""
s = Series(A.data, MultiIndex.from_arrays((A.row, A.col)))
s = s.sort_index()
s = s.to_sparse() # TODO: specify kind?
if ... | [
"Convert",
"a",
"scipy",
".",
"sparse",
".",
"coo_matrix",
"to",
"a",
"SparseSeries",
".",
"Use",
"the",
"defaults",
"given",
"in",
"the",
"SparseSeries",
"constructor",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/scipy_sparse.py#L121-L135 | [
"def",
"_coo_to_sparse_series",
"(",
"A",
",",
"dense_index",
"=",
"False",
")",
":",
"s",
"=",
"Series",
"(",
"A",
".",
"data",
",",
"MultiIndex",
".",
"from_arrays",
"(",
"(",
"A",
".",
"row",
",",
"A",
".",
"col",
")",
")",
")",
"s",
"=",
"s",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _to_M8 | Timestamp-like => dt64 | pandas/core/arrays/datetimes.py | def _to_M8(key, tz=None):
"""
Timestamp-like => dt64
"""
if not isinstance(key, Timestamp):
# this also converts strings
key = Timestamp(key)
if key.tzinfo is not None and tz is not None:
# Don't tz_localize(None) if key is already tz-aware
key = key.tz_co... | def _to_M8(key, tz=None):
"""
Timestamp-like => dt64
"""
if not isinstance(key, Timestamp):
# this also converts strings
key = Timestamp(key)
if key.tzinfo is not None and tz is not None:
# Don't tz_localize(None) if key is already tz-aware
key = key.tz_co... | [
"Timestamp",
"-",
"like",
"=",
">",
"dt64"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L72-L85 | [
"def",
"_to_M8",
"(",
"key",
",",
"tz",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"key",
",",
"Timestamp",
")",
":",
"# this also converts strings",
"key",
"=",
"Timestamp",
"(",
"key",
")",
"if",
"key",
".",
"tzinfo",
"is",
"not",
"None",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _dt_array_cmp | Wrap comparison operations to convert datetime-like to datetime64 | pandas/core/arrays/datetimes.py | def _dt_array_cmp(cls, op):
"""
Wrap comparison operations to convert datetime-like to datetime64
"""
opname = '__{name}__'.format(name=op.__name__)
nat_result = opname == '__ne__'
def wrapper(self, other):
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
retu... | def _dt_array_cmp(cls, op):
"""
Wrap comparison operations to convert datetime-like to datetime64
"""
opname = '__{name}__'.format(name=op.__name__)
nat_result = opname == '__ne__'
def wrapper(self, other):
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
retu... | [
"Wrap",
"comparison",
"operations",
"to",
"convert",
"datetime",
"-",
"like",
"to",
"datetime64"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L126-L207 | [
"def",
"_dt_array_cmp",
"(",
"cls",
",",
"op",
")",
":",
"opname",
"=",
"'__{name}__'",
".",
"format",
"(",
"name",
"=",
"op",
".",
"__name__",
")",
"nat_result",
"=",
"opname",
"==",
"'__ne__'",
"def",
"wrapper",
"(",
"self",
",",
"other",
")",
":",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | sequence_to_dt64ns | Parameters
----------
data : list-like
dtype : dtype, str, or None, default None
copy : bool, default False
tz : tzinfo, str, or None, default None
dayfirst : bool, default False
yearfirst : bool, default False
ambiguous : str, bool, or arraylike, default 'raise'
See pandas._libs... | pandas/core/arrays/datetimes.py | def sequence_to_dt64ns(data, dtype=None, copy=False,
tz=None,
dayfirst=False, yearfirst=False, ambiguous='raise',
int_as_wall_time=False):
"""
Parameters
----------
data : list-like
dtype : dtype, str, or None, default None
cop... | def sequence_to_dt64ns(data, dtype=None, copy=False,
tz=None,
dayfirst=False, yearfirst=False, ambiguous='raise',
int_as_wall_time=False):
"""
Parameters
----------
data : list-like
dtype : dtype, str, or None, default None
cop... | [
"Parameters",
"----------",
"data",
":",
"list",
"-",
"like",
"dtype",
":",
"dtype",
"str",
"or",
"None",
"default",
"None",
"copy",
":",
"bool",
"default",
"False",
"tz",
":",
"tzinfo",
"str",
"or",
"None",
"default",
"None",
"dayfirst",
":",
"bool",
"d... | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1669-L1800 | [
"def",
"sequence_to_dt64ns",
"(",
"data",
",",
"dtype",
"=",
"None",
",",
"copy",
"=",
"False",
",",
"tz",
"=",
"None",
",",
"dayfirst",
"=",
"False",
",",
"yearfirst",
"=",
"False",
",",
"ambiguous",
"=",
"'raise'",
",",
"int_as_wall_time",
"=",
"False"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | objects_to_datetime64ns | Convert data to array of timestamps.
Parameters
----------
data : np.ndarray[object]
dayfirst : bool
yearfirst : bool
utc : bool, default False
Whether to convert timezone-aware timestamps to UTC
errors : {'raise', 'ignore', 'coerce'}
allow_object : bool
Whether to retur... | pandas/core/arrays/datetimes.py | def objects_to_datetime64ns(data, dayfirst, yearfirst,
utc=False, errors="raise",
require_iso8601=False, allow_object=False):
"""
Convert data to array of timestamps.
Parameters
----------
data : np.ndarray[object]
dayfirst : bool
year... | def objects_to_datetime64ns(data, dayfirst, yearfirst,
utc=False, errors="raise",
require_iso8601=False, allow_object=False):
"""
Convert data to array of timestamps.
Parameters
----------
data : np.ndarray[object]
dayfirst : bool
year... | [
"Convert",
"data",
"to",
"array",
"of",
"timestamps",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1803-L1877 | [
"def",
"objects_to_datetime64ns",
"(",
"data",
",",
"dayfirst",
",",
"yearfirst",
",",
"utc",
"=",
"False",
",",
"errors",
"=",
"\"raise\"",
",",
"require_iso8601",
"=",
"False",
",",
"allow_object",
"=",
"False",
")",
":",
"assert",
"errors",
"in",
"[",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | maybe_convert_dtype | Convert data based on dtype conventions, issuing deprecation warnings
or errors where appropriate.
Parameters
----------
data : np.ndarray or pd.Index
copy : bool
Returns
-------
data : np.ndarray or pd.Index
copy : bool
Raises
------
TypeError : PeriodDType data is pa... | pandas/core/arrays/datetimes.py | def maybe_convert_dtype(data, copy):
"""
Convert data based on dtype conventions, issuing deprecation warnings
or errors where appropriate.
Parameters
----------
data : np.ndarray or pd.Index
copy : bool
Returns
-------
data : np.ndarray or pd.Index
copy : bool
Raises
... | def maybe_convert_dtype(data, copy):
"""
Convert data based on dtype conventions, issuing deprecation warnings
or errors where appropriate.
Parameters
----------
data : np.ndarray or pd.Index
copy : bool
Returns
-------
data : np.ndarray or pd.Index
copy : bool
Raises
... | [
"Convert",
"data",
"based",
"on",
"dtype",
"conventions",
"issuing",
"deprecation",
"warnings",
"or",
"errors",
"where",
"appropriate",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1880-L1932 | [
"def",
"maybe_convert_dtype",
"(",
"data",
",",
"copy",
")",
":",
"if",
"is_float_dtype",
"(",
"data",
")",
":",
"# Note: we must cast to datetime64[ns] here in order to treat these",
"# as wall-times instead of UTC timestamps.",
"data",
"=",
"data",
".",
"astype",
"(",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | maybe_infer_tz | If a timezone is inferred from data, check that it is compatible with
the user-provided timezone, if any.
Parameters
----------
tz : tzinfo or None
inferred_tz : tzinfo or None
Returns
-------
tz : tzinfo or None
Raises
------
TypeError : if both timezones are present but ... | pandas/core/arrays/datetimes.py | def maybe_infer_tz(tz, inferred_tz):
"""
If a timezone is inferred from data, check that it is compatible with
the user-provided timezone, if any.
Parameters
----------
tz : tzinfo or None
inferred_tz : tzinfo or None
Returns
-------
tz : tzinfo or None
Raises
------
... | def maybe_infer_tz(tz, inferred_tz):
"""
If a timezone is inferred from data, check that it is compatible with
the user-provided timezone, if any.
Parameters
----------
tz : tzinfo or None
inferred_tz : tzinfo or None
Returns
-------
tz : tzinfo or None
Raises
------
... | [
"If",
"a",
"timezone",
"is",
"inferred",
"from",
"data",
"check",
"that",
"it",
"is",
"compatible",
"with",
"the",
"user",
"-",
"provided",
"timezone",
"if",
"any",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1938-L1964 | [
"def",
"maybe_infer_tz",
"(",
"tz",
",",
"inferred_tz",
")",
":",
"if",
"tz",
"is",
"None",
":",
"tz",
"=",
"inferred_tz",
"elif",
"inferred_tz",
"is",
"None",
":",
"pass",
"elif",
"not",
"timezones",
".",
"tz_compare",
"(",
"tz",
",",
"inferred_tz",
")"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _validate_dt64_dtype | Check that a dtype, if passed, represents either a numpy datetime64[ns]
dtype or a pandas DatetimeTZDtype.
Parameters
----------
dtype : object
Returns
-------
dtype : None, numpy.dtype, or DatetimeTZDtype
Raises
------
ValueError : invalid dtype
Notes
-----
Unlik... | pandas/core/arrays/datetimes.py | def _validate_dt64_dtype(dtype):
"""
Check that a dtype, if passed, represents either a numpy datetime64[ns]
dtype or a pandas DatetimeTZDtype.
Parameters
----------
dtype : object
Returns
-------
dtype : None, numpy.dtype, or DatetimeTZDtype
Raises
------
ValueError :... | def _validate_dt64_dtype(dtype):
"""
Check that a dtype, if passed, represents either a numpy datetime64[ns]
dtype or a pandas DatetimeTZDtype.
Parameters
----------
dtype : object
Returns
-------
dtype : None, numpy.dtype, or DatetimeTZDtype
Raises
------
ValueError :... | [
"Check",
"that",
"a",
"dtype",
"if",
"passed",
"represents",
"either",
"a",
"numpy",
"datetime64",
"[",
"ns",
"]",
"dtype",
"or",
"a",
"pandas",
"DatetimeTZDtype",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1967-L2005 | [
"def",
"_validate_dt64_dtype",
"(",
"dtype",
")",
":",
"if",
"dtype",
"is",
"not",
"None",
":",
"dtype",
"=",
"pandas_dtype",
"(",
"dtype",
")",
"if",
"is_dtype_equal",
"(",
"dtype",
",",
"np",
".",
"dtype",
"(",
"\"M8\"",
")",
")",
":",
"# no precision,... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | validate_tz_from_dtype | If the given dtype is a DatetimeTZDtype, extract the implied
tzinfo object from it and check that it does not conflict with the given
tz.
Parameters
----------
dtype : dtype, str
tz : None, tzinfo
Returns
-------
tz : consensus tzinfo
Raises
------
ValueError : on tzin... | pandas/core/arrays/datetimes.py | def validate_tz_from_dtype(dtype, tz):
"""
If the given dtype is a DatetimeTZDtype, extract the implied
tzinfo object from it and check that it does not conflict with the given
tz.
Parameters
----------
dtype : dtype, str
tz : None, tzinfo
Returns
-------
tz : consensus tzi... | def validate_tz_from_dtype(dtype, tz):
"""
If the given dtype is a DatetimeTZDtype, extract the implied
tzinfo object from it and check that it does not conflict with the given
tz.
Parameters
----------
dtype : dtype, str
tz : None, tzinfo
Returns
-------
tz : consensus tzi... | [
"If",
"the",
"given",
"dtype",
"is",
"a",
"DatetimeTZDtype",
"extract",
"the",
"implied",
"tzinfo",
"object",
"from",
"it",
"and",
"check",
"that",
"it",
"does",
"not",
"conflict",
"with",
"the",
"given",
"tz",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L2008-L2051 | [
"def",
"validate_tz_from_dtype",
"(",
"dtype",
",",
"tz",
")",
":",
"if",
"dtype",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"dtype",
",",
"str",
")",
":",
"try",
":",
"dtype",
"=",
"DatetimeTZDtype",
".",
"construct_from_string",
"(",
"dtype",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _infer_tz_from_endpoints | If a timezone is not explicitly given via `tz`, see if one can
be inferred from the `start` and `end` endpoints. If more than one
of these inputs provides a timezone, require that they all agree.
Parameters
----------
start : Timestamp
end : Timestamp
tz : tzinfo or None
Returns
-... | pandas/core/arrays/datetimes.py | def _infer_tz_from_endpoints(start, end, tz):
"""
If a timezone is not explicitly given via `tz`, see if one can
be inferred from the `start` and `end` endpoints. If more than one
of these inputs provides a timezone, require that they all agree.
Parameters
----------
start : Timestamp
... | def _infer_tz_from_endpoints(start, end, tz):
"""
If a timezone is not explicitly given via `tz`, see if one can
be inferred from the `start` and `end` endpoints. If more than one
of these inputs provides a timezone, require that they all agree.
Parameters
----------
start : Timestamp
... | [
"If",
"a",
"timezone",
"is",
"not",
"explicitly",
"given",
"via",
"tz",
"see",
"if",
"one",
"can",
"be",
"inferred",
"from",
"the",
"start",
"and",
"end",
"endpoints",
".",
"If",
"more",
"than",
"one",
"of",
"these",
"inputs",
"provides",
"a",
"timezone"... | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L2054-L2091 | [
"def",
"_infer_tz_from_endpoints",
"(",
"start",
",",
"end",
",",
"tz",
")",
":",
"try",
":",
"inferred_tz",
"=",
"timezones",
".",
"infer_tzinfo",
"(",
"start",
",",
"end",
")",
"except",
"Exception",
":",
"raise",
"TypeError",
"(",
"'Start and end cannot bot... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _maybe_localize_point | Localize a start or end Timestamp to the timezone of the corresponding
start or end Timestamp
Parameters
----------
ts : start or end Timestamp to potentially localize
is_none : argument that should be None
is_not_none : argument that should not be None
freq : Tick, DateOffset, or None
... | pandas/core/arrays/datetimes.py | def _maybe_localize_point(ts, is_none, is_not_none, freq, tz):
"""
Localize a start or end Timestamp to the timezone of the corresponding
start or end Timestamp
Parameters
----------
ts : start or end Timestamp to potentially localize
is_none : argument that should be None
is_not_none :... | def _maybe_localize_point(ts, is_none, is_not_none, freq, tz):
"""
Localize a start or end Timestamp to the timezone of the corresponding
start or end Timestamp
Parameters
----------
ts : start or end Timestamp to potentially localize
is_none : argument that should be None
is_not_none :... | [
"Localize",
"a",
"start",
"or",
"end",
"Timestamp",
"to",
"the",
"timezone",
"of",
"the",
"corresponding",
"start",
"or",
"end",
"Timestamp"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L2114-L2140 | [
"def",
"_maybe_localize_point",
"(",
"ts",
",",
"is_none",
",",
"is_not_none",
",",
"freq",
",",
"tz",
")",
":",
"# Make sure start and end are timezone localized if:",
"# 1) freq = a Timedelta-like frequency (Tick)",
"# 2) freq = None i.e. generating a linspaced range",
"if",
"i... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DatetimeArray._sub_datetime_arraylike | subtract DatetimeArray/Index or ndarray[datetime64] | pandas/core/arrays/datetimes.py | def _sub_datetime_arraylike(self, other):
"""subtract DatetimeArray/Index or ndarray[datetime64]"""
if len(self) != len(other):
raise ValueError("cannot add indices of unequal length")
if isinstance(other, np.ndarray):
assert is_datetime64_dtype(other)
other ... | def _sub_datetime_arraylike(self, other):
"""subtract DatetimeArray/Index or ndarray[datetime64]"""
if len(self) != len(other):
raise ValueError("cannot add indices of unequal length")
if isinstance(other, np.ndarray):
assert is_datetime64_dtype(other)
other ... | [
"subtract",
"DatetimeArray",
"/",
"Index",
"or",
"ndarray",
"[",
"datetime64",
"]"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L698-L720 | [
"def",
"_sub_datetime_arraylike",
"(",
"self",
",",
"other",
")",
":",
"if",
"len",
"(",
"self",
")",
"!=",
"len",
"(",
"other",
")",
":",
"raise",
"ValueError",
"(",
"\"cannot add indices of unequal length\"",
")",
"if",
"isinstance",
"(",
"other",
",",
"np... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DatetimeArray._add_delta | Add a timedelta-like, Tick, or TimedeltaIndex-like object
to self, yielding a new DatetimeArray
Parameters
----------
other : {timedelta, np.timedelta64, Tick,
TimedeltaIndex, ndarray[timedelta64]}
Returns
-------
result : DatetimeArray | pandas/core/arrays/datetimes.py | def _add_delta(self, delta):
"""
Add a timedelta-like, Tick, or TimedeltaIndex-like object
to self, yielding a new DatetimeArray
Parameters
----------
other : {timedelta, np.timedelta64, Tick,
TimedeltaIndex, ndarray[timedelta64]}
Returns
... | def _add_delta(self, delta):
"""
Add a timedelta-like, Tick, or TimedeltaIndex-like object
to self, yielding a new DatetimeArray
Parameters
----------
other : {timedelta, np.timedelta64, Tick,
TimedeltaIndex, ndarray[timedelta64]}
Returns
... | [
"Add",
"a",
"timedelta",
"-",
"like",
"Tick",
"or",
"TimedeltaIndex",
"-",
"like",
"object",
"to",
"self",
"yielding",
"a",
"new",
"DatetimeArray"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L759-L774 | [
"def",
"_add_delta",
"(",
"self",
",",
"delta",
")",
":",
"new_values",
"=",
"super",
"(",
")",
".",
"_add_delta",
"(",
"delta",
")",
"return",
"type",
"(",
"self",
")",
".",
"_from_sequence",
"(",
"new_values",
",",
"tz",
"=",
"self",
".",
"tz",
","... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DatetimeArray.tz_convert | Convert tz-aware Datetime Array/Index from one time zone to another.
Parameters
----------
tz : str, pytz.timezone, dateutil.tz.tzfile or None
Time zone for time. Corresponding timestamps would be converted
to this time zone of the Datetime Array/Index. A `tz` of None wi... | pandas/core/arrays/datetimes.py | def tz_convert(self, tz):
"""
Convert tz-aware Datetime Array/Index from one time zone to another.
Parameters
----------
tz : str, pytz.timezone, dateutil.tz.tzfile or None
Time zone for time. Corresponding timestamps would be converted
to this time zone ... | def tz_convert(self, tz):
"""
Convert tz-aware Datetime Array/Index from one time zone to another.
Parameters
----------
tz : str, pytz.timezone, dateutil.tz.tzfile or None
Time zone for time. Corresponding timestamps would be converted
to this time zone ... | [
"Convert",
"tz",
"-",
"aware",
"Datetime",
"Array",
"/",
"Index",
"from",
"one",
"time",
"zone",
"to",
"another",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L788-L861 | [
"def",
"tz_convert",
"(",
"self",
",",
"tz",
")",
":",
"tz",
"=",
"timezones",
".",
"maybe_get_tz",
"(",
"tz",
")",
"if",
"self",
".",
"tz",
"is",
"None",
":",
"# tz naive, use tz_localize",
"raise",
"TypeError",
"(",
"'Cannot convert tz-naive timestamps, use '"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DatetimeArray.tz_localize | Localize tz-naive Datetime Array/Index to tz-aware
Datetime Array/Index.
This method takes a time zone (tz) naive Datetime Array/Index object
and makes this time zone aware. It does not move the time to another
time zone.
Time zone localization helps to switch from time zone awa... | pandas/core/arrays/datetimes.py | def tz_localize(self, tz, ambiguous='raise', nonexistent='raise',
errors=None):
"""
Localize tz-naive Datetime Array/Index to tz-aware
Datetime Array/Index.
This method takes a time zone (tz) naive Datetime Array/Index object
and makes this time zone aware. I... | def tz_localize(self, tz, ambiguous='raise', nonexistent='raise',
errors=None):
"""
Localize tz-naive Datetime Array/Index to tz-aware
Datetime Array/Index.
This method takes a time zone (tz) naive Datetime Array/Index object
and makes this time zone aware. I... | [
"Localize",
"tz",
"-",
"naive",
"Datetime",
"Array",
"/",
"Index",
"to",
"tz",
"-",
"aware",
"Datetime",
"Array",
"/",
"Index",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L863-L1047 | [
"def",
"tz_localize",
"(",
"self",
",",
"tz",
",",
"ambiguous",
"=",
"'raise'",
",",
"nonexistent",
"=",
"'raise'",
",",
"errors",
"=",
"None",
")",
":",
"if",
"errors",
"is",
"not",
"None",
":",
"warnings",
".",
"warn",
"(",
"\"The errors argument is depr... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DatetimeArray.normalize | Convert times to midnight.
The time component of the date-time is converted to midnight i.e.
00:00:00. This is useful in cases, when the time does not matter.
Length is unaltered. The timezones are unaffected.
This method is available on Series with datetime values under
the ``... | pandas/core/arrays/datetimes.py | def normalize(self):
"""
Convert times to midnight.
The time component of the date-time is converted to midnight i.e.
00:00:00. This is useful in cases, when the time does not matter.
Length is unaltered. The timezones are unaffected.
This method is available on Series ... | def normalize(self):
"""
Convert times to midnight.
The time component of the date-time is converted to midnight i.e.
00:00:00. This is useful in cases, when the time does not matter.
Length is unaltered. The timezones are unaffected.
This method is available on Series ... | [
"Convert",
"times",
"to",
"midnight",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1063-L1110 | [
"def",
"normalize",
"(",
"self",
")",
":",
"if",
"self",
".",
"tz",
"is",
"None",
"or",
"timezones",
".",
"is_utc",
"(",
"self",
".",
"tz",
")",
":",
"not_null",
"=",
"~",
"self",
".",
"isna",
"(",
")",
"DAY_NS",
"=",
"ccalendar",
".",
"DAY_SECONDS... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DatetimeArray.to_period | Cast to PeriodArray/Index at a particular frequency.
Converts DatetimeArray/Index to PeriodArray/Index.
Parameters
----------
freq : str or Offset, optional
One of pandas' :ref:`offset strings <timeseries.offset_aliases>`
or an Offset object. Will be inferred by... | pandas/core/arrays/datetimes.py | def to_period(self, freq=None):
"""
Cast to PeriodArray/Index at a particular frequency.
Converts DatetimeArray/Index to PeriodArray/Index.
Parameters
----------
freq : str or Offset, optional
One of pandas' :ref:`offset strings <timeseries.offset_aliases>`
... | def to_period(self, freq=None):
"""
Cast to PeriodArray/Index at a particular frequency.
Converts DatetimeArray/Index to PeriodArray/Index.
Parameters
----------
freq : str or Offset, optional
One of pandas' :ref:`offset strings <timeseries.offset_aliases>`
... | [
"Cast",
"to",
"PeriodArray",
"/",
"Index",
"at",
"a",
"particular",
"frequency",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1112-L1171 | [
"def",
"to_period",
"(",
"self",
",",
"freq",
"=",
"None",
")",
":",
"from",
"pandas",
".",
"core",
".",
"arrays",
"import",
"PeriodArray",
"if",
"self",
".",
"tz",
"is",
"not",
"None",
":",
"warnings",
".",
"warn",
"(",
"\"Converting to PeriodArray/Index ... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DatetimeArray.to_perioddelta | Calculate TimedeltaArray of difference between index
values and index converted to PeriodArray at specified
freq. Used for vectorized offsets
Parameters
----------
freq : Period frequency
Returns
-------
TimedeltaArray/Index | pandas/core/arrays/datetimes.py | def to_perioddelta(self, freq):
"""
Calculate TimedeltaArray of difference between index
values and index converted to PeriodArray at specified
freq. Used for vectorized offsets
Parameters
----------
freq : Period frequency
Returns
-------
... | def to_perioddelta(self, freq):
"""
Calculate TimedeltaArray of difference between index
values and index converted to PeriodArray at specified
freq. Used for vectorized offsets
Parameters
----------
freq : Period frequency
Returns
-------
... | [
"Calculate",
"TimedeltaArray",
"of",
"difference",
"between",
"index",
"values",
"and",
"index",
"converted",
"to",
"PeriodArray",
"at",
"specified",
"freq",
".",
"Used",
"for",
"vectorized",
"offsets"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1173-L1191 | [
"def",
"to_perioddelta",
"(",
"self",
",",
"freq",
")",
":",
"# TODO: consider privatizing (discussion in GH#23113)",
"from",
"pandas",
".",
"core",
".",
"arrays",
".",
"timedeltas",
"import",
"TimedeltaArray",
"i8delta",
"=",
"self",
".",
"asi8",
"-",
"self",
"."... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DatetimeArray.month_name | Return the month names of the DateTimeIndex with specified locale.
.. versionadded:: 0.23.0
Parameters
----------
locale : str, optional
Locale determining the language in which to return the month name.
Default is English locale.
Returns
------... | pandas/core/arrays/datetimes.py | def month_name(self, locale=None):
"""
Return the month names of the DateTimeIndex with specified locale.
.. versionadded:: 0.23.0
Parameters
----------
locale : str, optional
Locale determining the language in which to return the month name.
Def... | def month_name(self, locale=None):
"""
Return the month names of the DateTimeIndex with specified locale.
.. versionadded:: 0.23.0
Parameters
----------
locale : str, optional
Locale determining the language in which to return the month name.
Def... | [
"Return",
"the",
"month",
"names",
"of",
"the",
"DateTimeIndex",
"with",
"specified",
"locale",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1196-L1230 | [
"def",
"month_name",
"(",
"self",
",",
"locale",
"=",
"None",
")",
":",
"if",
"self",
".",
"tz",
"is",
"not",
"None",
"and",
"not",
"timezones",
".",
"is_utc",
"(",
"self",
".",
"tz",
")",
":",
"values",
"=",
"self",
".",
"_local_timestamps",
"(",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DatetimeArray.time | Returns numpy array of datetime.time. The time part of the Timestamps. | pandas/core/arrays/datetimes.py | def time(self):
"""
Returns numpy array of datetime.time. The time part of the Timestamps.
"""
# If the Timestamps have a timezone that is not UTC,
# convert them into their i8 representation while
# keeping their timezone and not using UTC
if self.tz is not None ... | def time(self):
"""
Returns numpy array of datetime.time. The time part of the Timestamps.
"""
# If the Timestamps have a timezone that is not UTC,
# convert them into their i8 representation while
# keeping their timezone and not using UTC
if self.tz is not None ... | [
"Returns",
"numpy",
"array",
"of",
"datetime",
".",
"time",
".",
"The",
"time",
"part",
"of",
"the",
"Timestamps",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1269-L1281 | [
"def",
"time",
"(",
"self",
")",
":",
"# If the Timestamps have a timezone that is not UTC,",
"# convert them into their i8 representation while",
"# keeping their timezone and not using UTC",
"if",
"self",
".",
"tz",
"is",
"not",
"None",
"and",
"not",
"timezones",
".",
"is_u... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DatetimeArray.to_julian_date | Convert Datetime Array to float64 ndarray of Julian Dates.
0 Julian date is noon January 1, 4713 BC.
http://en.wikipedia.org/wiki/Julian_day | pandas/core/arrays/datetimes.py | def to_julian_date(self):
"""
Convert Datetime Array to float64 ndarray of Julian Dates.
0 Julian date is noon January 1, 4713 BC.
http://en.wikipedia.org/wiki/Julian_day
"""
# http://mysite.verizon.net/aesir_research/date/jdalg2.htm
year = np.asarray(self.year)
... | def to_julian_date(self):
"""
Convert Datetime Array to float64 ndarray of Julian Dates.
0 Julian date is noon January 1, 4713 BC.
http://en.wikipedia.org/wiki/Julian_day
"""
# http://mysite.verizon.net/aesir_research/date/jdalg2.htm
year = np.asarray(self.year)
... | [
"Convert",
"Datetime",
"Array",
"to",
"float64",
"ndarray",
"of",
"Julian",
"Dates",
".",
"0",
"Julian",
"date",
"is",
"noon",
"January",
"1",
"4713",
"BC",
".",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Julian_day"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1634-L1660 | [
"def",
"to_julian_date",
"(",
"self",
")",
":",
"# http://mysite.verizon.net/aesir_research/date/jdalg2.htm",
"year",
"=",
"np",
".",
"asarray",
"(",
"self",
".",
"year",
")",
"month",
"=",
"np",
".",
"asarray",
"(",
"self",
".",
"month",
")",
"day",
"=",
"n... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | get_api_items | Yield information about all public API items.
Parse api.rst file from the documentation, and extract all the functions,
methods, classes, attributes... This should include all pandas public API.
Parameters
----------
api_doc_fd : file descriptor
A file descriptor of the API documentation p... | scripts/validate_docstrings.py | def get_api_items(api_doc_fd):
"""
Yield information about all public API items.
Parse api.rst file from the documentation, and extract all the functions,
methods, classes, attributes... This should include all pandas public API.
Parameters
----------
api_doc_fd : file descriptor
A... | def get_api_items(api_doc_fd):
"""
Yield information about all public API items.
Parse api.rst file from the documentation, and extract all the functions,
methods, classes, attributes... This should include all pandas public API.
Parameters
----------
api_doc_fd : file descriptor
A... | [
"Yield",
"information",
"about",
"all",
"public",
"API",
"items",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/validate_docstrings.py#L158-L223 | [
"def",
"get_api_items",
"(",
"api_doc_fd",
")",
":",
"current_module",
"=",
"'pandas'",
"previous_line",
"=",
"current_section",
"=",
"current_subsection",
"=",
"''",
"position",
"=",
"None",
"for",
"line",
"in",
"api_doc_fd",
":",
"line",
"=",
"line",
".",
"s... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | get_validation_data | Validate the docstring.
Parameters
----------
doc : Docstring
A Docstring object with the given function name.
Returns
-------
tuple
errors : list of tuple
Errors occurred during validation.
warnings : list of tuple
Warnings occurred during valid... | scripts/validate_docstrings.py | def get_validation_data(doc):
"""
Validate the docstring.
Parameters
----------
doc : Docstring
A Docstring object with the given function name.
Returns
-------
tuple
errors : list of tuple
Errors occurred during validation.
warnings : list of tuple
... | def get_validation_data(doc):
"""
Validate the docstring.
Parameters
----------
doc : Docstring
A Docstring object with the given function name.
Returns
-------
tuple
errors : list of tuple
Errors occurred during validation.
warnings : list of tuple
... | [
"Validate",
"the",
"docstring",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/validate_docstrings.py#L599-L785 | [
"def",
"get_validation_data",
"(",
"doc",
")",
":",
"errs",
"=",
"[",
"]",
"wrns",
"=",
"[",
"]",
"if",
"not",
"doc",
".",
"raw_doc",
":",
"errs",
".",
"append",
"(",
"error",
"(",
"'GL08'",
")",
")",
"return",
"errs",
",",
"wrns",
",",
"''",
"if... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | validate_one | Validate the docstring for the given func_name
Parameters
----------
func_name : function
Function whose docstring will be evaluated (e.g. pandas.read_csv).
Returns
-------
dict
A dictionary containing all the information obtained from validating
the docstring. | scripts/validate_docstrings.py | def validate_one(func_name):
"""
Validate the docstring for the given func_name
Parameters
----------
func_name : function
Function whose docstring will be evaluated (e.g. pandas.read_csv).
Returns
-------
dict
A dictionary containing all the information obtained from v... | def validate_one(func_name):
"""
Validate the docstring for the given func_name
Parameters
----------
func_name : function
Function whose docstring will be evaluated (e.g. pandas.read_csv).
Returns
-------
dict
A dictionary containing all the information obtained from v... | [
"Validate",
"the",
"docstring",
"for",
"the",
"given",
"func_name"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/validate_docstrings.py#L788-L813 | [
"def",
"validate_one",
"(",
"func_name",
")",
":",
"doc",
"=",
"Docstring",
"(",
"func_name",
")",
"errs",
",",
"wrns",
",",
"examples_errs",
"=",
"get_validation_data",
"(",
"doc",
")",
"return",
"{",
"'type'",
":",
"doc",
".",
"type",
",",
"'docstring'",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | validate_all | Execute the validation of all docstrings, and return a dict with the
results.
Parameters
----------
prefix : str or None
If provided, only the docstrings that start with this pattern will be
validated. If None, all docstrings will be validated.
ignore_deprecated: bool, default False... | scripts/validate_docstrings.py | def validate_all(prefix, ignore_deprecated=False):
"""
Execute the validation of all docstrings, and return a dict with the
results.
Parameters
----------
prefix : str or None
If provided, only the docstrings that start with this pattern will be
validated. If None, all docstring... | def validate_all(prefix, ignore_deprecated=False):
"""
Execute the validation of all docstrings, and return a dict with the
results.
Parameters
----------
prefix : str or None
If provided, only the docstrings that start with this pattern will be
validated. If None, all docstring... | [
"Execute",
"the",
"validation",
"of",
"all",
"docstrings",
"and",
"return",
"a",
"dict",
"with",
"the",
"results",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/validate_docstrings.py#L816-L877 | [
"def",
"validate_all",
"(",
"prefix",
",",
"ignore_deprecated",
"=",
"False",
")",
":",
"result",
"=",
"{",
"}",
"seen",
"=",
"{",
"}",
"# functions from the API docs",
"api_doc_fnames",
"=",
"os",
".",
"path",
".",
"join",
"(",
"BASE_PATH",
",",
"'doc'",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Docstring._load_obj | Import Python object from its name as string.
Parameters
----------
name : str
Object name to import (e.g. pandas.Series.str.upper)
Returns
-------
object
Python object that can be a class, method, function...
Examples
--------
... | scripts/validate_docstrings.py | def _load_obj(name):
"""
Import Python object from its name as string.
Parameters
----------
name : str
Object name to import (e.g. pandas.Series.str.upper)
Returns
-------
object
Python object that can be a class, method, functio... | def _load_obj(name):
"""
Import Python object from its name as string.
Parameters
----------
name : str
Object name to import (e.g. pandas.Series.str.upper)
Returns
-------
object
Python object that can be a class, method, functio... | [
"Import",
"Python",
"object",
"from",
"its",
"name",
"as",
"string",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/validate_docstrings.py#L240-L277 | [
"def",
"_load_obj",
"(",
"name",
")",
":",
"for",
"maxsplit",
"in",
"range",
"(",
"1",
",",
"name",
".",
"count",
"(",
"'.'",
")",
"+",
"1",
")",
":",
"# TODO when py3 only replace by: module, *func_parts = ...",
"func_name_split",
"=",
"name",
".",
"rsplit",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Docstring._to_original_callable | Find the Python object that contains the source code of the object.
This is useful to find the place in the source code (file and line
number) where a docstring is defined. It does not currently work for
all cases, but it should help find some (properties...). | scripts/validate_docstrings.py | def _to_original_callable(obj):
"""
Find the Python object that contains the source code of the object.
This is useful to find the place in the source code (file and line
number) where a docstring is defined. It does not currently work for
all cases, but it should help find some... | def _to_original_callable(obj):
"""
Find the Python object that contains the source code of the object.
This is useful to find the place in the source code (file and line
number) where a docstring is defined. It does not currently work for
all cases, but it should help find some... | [
"Find",
"the",
"Python",
"object",
"that",
"contains",
"the",
"source",
"code",
"of",
"the",
"object",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/validate_docstrings.py#L280-L301 | [
"def",
"_to_original_callable",
"(",
"obj",
")",
":",
"while",
"True",
":",
"if",
"inspect",
".",
"isfunction",
"(",
"obj",
")",
"or",
"inspect",
".",
"isclass",
"(",
"obj",
")",
":",
"f",
"=",
"inspect",
".",
"getfile",
"(",
"obj",
")",
"if",
"f",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Docstring.source_file_name | File name where the object is implemented (e.g. pandas/core/frame.py). | scripts/validate_docstrings.py | def source_file_name(self):
"""
File name where the object is implemented (e.g. pandas/core/frame.py).
"""
try:
fname = inspect.getsourcefile(self.code_obj)
except TypeError:
# In some cases the object is something complex like a cython
# objec... | def source_file_name(self):
"""
File name where the object is implemented (e.g. pandas/core/frame.py).
"""
try:
fname = inspect.getsourcefile(self.code_obj)
except TypeError:
# In some cases the object is something complex like a cython
# objec... | [
"File",
"name",
"where",
"the",
"object",
"is",
"implemented",
"(",
"e",
".",
"g",
".",
"pandas",
"/",
"core",
"/",
"frame",
".",
"py",
")",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/validate_docstrings.py#L314-L328 | [
"def",
"source_file_name",
"(",
"self",
")",
":",
"try",
":",
"fname",
"=",
"inspect",
".",
"getsourcefile",
"(",
"self",
".",
"code_obj",
")",
"except",
"TypeError",
":",
"# In some cases the object is something complex like a cython",
"# object that can't be easily intr... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.