repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
pandas-dev/pandas | pandas/core/arrays/sparse.py | SparseArray.astype | def astype(self, dtype=None, copy=True):
"""
Change the dtype of a SparseArray.
The output will always be a SparseArray. To convert to a dense
ndarray with a certain dtype, use :meth:`numpy.asarray`.
Parameters
----------
dtype : np.dtype or ExtensionDtype
... | python | def astype(self, dtype=None, copy=True):
"""
Change the dtype of a SparseArray.
The output will always be a SparseArray. To convert to a dense
ndarray with a certain dtype, use :meth:`numpy.asarray`.
Parameters
----------
dtype : np.dtype or ExtensionDtype
... | [
"def",
"astype",
"(",
"self",
",",
"dtype",
"=",
"None",
",",
"copy",
"=",
"True",
")",
":",
"dtype",
"=",
"self",
".",
"dtype",
".",
"update_dtype",
"(",
"dtype",
")",
"subtype",
"=",
"dtype",
".",
"_subtype_with_str",
"sp_values",
"=",
"astype_nansafe"... | Change the dtype of a SparseArray.
The output will always be a SparseArray. To convert to a dense
ndarray with a certain dtype, use :meth:`numpy.asarray`.
Parameters
----------
dtype : np.dtype or ExtensionDtype
For SparseDtype, this changes the dtype of
... | [
"Change",
"the",
"dtype",
"of",
"a",
"SparseArray",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L1278-L1345 | train |
pandas-dev/pandas | pandas/core/arrays/sparse.py | SparseArray.map | def map(self, mapper):
"""
Map categories using input correspondence (dict, Series, or function).
Parameters
----------
mapper : dict, Series, callable
The correspondence from old values to new.
Returns
-------
SparseArray
The out... | python | def map(self, mapper):
"""
Map categories using input correspondence (dict, Series, or function).
Parameters
----------
mapper : dict, Series, callable
The correspondence from old values to new.
Returns
-------
SparseArray
The out... | [
"def",
"map",
"(",
"self",
",",
"mapper",
")",
":",
"# this is used in apply.",
"# We get hit since we're an \"is_extension_type\" but regular extension",
"# types are not hit. This may be worth adding to the interface.",
"if",
"isinstance",
"(",
"mapper",
",",
"ABCSeries",
")",
... | Map categories using input correspondence (dict, Series, or function).
Parameters
----------
mapper : dict, Series, callable
The correspondence from old values to new.
Returns
-------
SparseArray
The output array will have the same density as the... | [
"Map",
"categories",
"using",
"input",
"correspondence",
"(",
"dict",
"Series",
"or",
"function",
")",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L1347-L1398 | train |
pandas-dev/pandas | pandas/core/arrays/sparse.py | SparseArray.all | def all(self, axis=None, *args, **kwargs):
"""
Tests whether all elements evaluate True
Returns
-------
all : bool
See Also
--------
numpy.all
"""
nv.validate_all(args, kwargs)
values = self.sp_values
if len(values) != l... | python | def all(self, axis=None, *args, **kwargs):
"""
Tests whether all elements evaluate True
Returns
-------
all : bool
See Also
--------
numpy.all
"""
nv.validate_all(args, kwargs)
values = self.sp_values
if len(values) != l... | [
"def",
"all",
"(",
"self",
",",
"axis",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"nv",
".",
"validate_all",
"(",
"args",
",",
"kwargs",
")",
"values",
"=",
"self",
".",
"sp_values",
"if",
"len",
"(",
"values",
")",
"!=",
... | Tests whether all elements evaluate True
Returns
-------
all : bool
See Also
--------
numpy.all | [
"Tests",
"whether",
"all",
"elements",
"evaluate",
"True"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L1461-L1480 | train |
pandas-dev/pandas | pandas/core/arrays/sparse.py | SparseArray.any | def any(self, axis=0, *args, **kwargs):
"""
Tests whether at least one of elements evaluate True
Returns
-------
any : bool
See Also
--------
numpy.any
"""
nv.validate_any(args, kwargs)
values = self.sp_values
if len(val... | python | def any(self, axis=0, *args, **kwargs):
"""
Tests whether at least one of elements evaluate True
Returns
-------
any : bool
See Also
--------
numpy.any
"""
nv.validate_any(args, kwargs)
values = self.sp_values
if len(val... | [
"def",
"any",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"nv",
".",
"validate_any",
"(",
"args",
",",
"kwargs",
")",
"values",
"=",
"self",
".",
"sp_values",
"if",
"len",
"(",
"values",
")",
"!=",
"... | Tests whether at least one of elements evaluate True
Returns
-------
any : bool
See Also
--------
numpy.any | [
"Tests",
"whether",
"at",
"least",
"one",
"of",
"elements",
"evaluate",
"True"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L1482-L1501 | train |
pandas-dev/pandas | pandas/core/arrays/sparse.py | SparseArray.sum | def sum(self, axis=0, *args, **kwargs):
"""
Sum of non-NA/null values
Returns
-------
sum : float
"""
nv.validate_sum(args, kwargs)
valid_vals = self._valid_sp_values
sp_sum = valid_vals.sum()
if self._null_fill_value:
return s... | python | def sum(self, axis=0, *args, **kwargs):
"""
Sum of non-NA/null values
Returns
-------
sum : float
"""
nv.validate_sum(args, kwargs)
valid_vals = self._valid_sp_values
sp_sum = valid_vals.sum()
if self._null_fill_value:
return s... | [
"def",
"sum",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"nv",
".",
"validate_sum",
"(",
"args",
",",
"kwargs",
")",
"valid_vals",
"=",
"self",
".",
"_valid_sp_values",
"sp_sum",
"=",
"valid_vals",
".",
... | Sum of non-NA/null values
Returns
-------
sum : float | [
"Sum",
"of",
"non",
"-",
"NA",
"/",
"null",
"values"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L1503-L1518 | train |
pandas-dev/pandas | pandas/core/arrays/sparse.py | SparseArray.cumsum | def cumsum(self, axis=0, *args, **kwargs):
"""
Cumulative sum of non-NA/null values.
When performing the cumulative summation, any non-NA/null values will
be skipped. The resulting SparseArray will preserve the locations of
NaN values, but the fill value will be `np.nan` regardl... | python | def cumsum(self, axis=0, *args, **kwargs):
"""
Cumulative sum of non-NA/null values.
When performing the cumulative summation, any non-NA/null values will
be skipped. The resulting SparseArray will preserve the locations of
NaN values, but the fill value will be `np.nan` regardl... | [
"def",
"cumsum",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"nv",
".",
"validate_cumsum",
"(",
"args",
",",
"kwargs",
")",
"if",
"axis",
"is",
"not",
"None",
"and",
"axis",
">=",
"self",
".",
"ndim",
... | Cumulative sum of non-NA/null values.
When performing the cumulative summation, any non-NA/null values will
be skipped. The resulting SparseArray will preserve the locations of
NaN values, but the fill value will be `np.nan` regardless.
Parameters
----------
axis : int ... | [
"Cumulative",
"sum",
"of",
"non",
"-",
"NA",
"/",
"null",
"values",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L1520-L1547 | train |
pandas-dev/pandas | pandas/core/arrays/sparse.py | SparseArray.mean | def mean(self, axis=0, *args, **kwargs):
"""
Mean of non-NA/null values
Returns
-------
mean : float
"""
nv.validate_mean(args, kwargs)
valid_vals = self._valid_sp_values
sp_sum = valid_vals.sum()
ct = len(valid_vals)
if self._nul... | python | def mean(self, axis=0, *args, **kwargs):
"""
Mean of non-NA/null values
Returns
-------
mean : float
"""
nv.validate_mean(args, kwargs)
valid_vals = self._valid_sp_values
sp_sum = valid_vals.sum()
ct = len(valid_vals)
if self._nul... | [
"def",
"mean",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"nv",
".",
"validate_mean",
"(",
"args",
",",
"kwargs",
")",
"valid_vals",
"=",
"self",
".",
"_valid_sp_values",
"sp_sum",
"=",
"valid_vals",
".",... | Mean of non-NA/null values
Returns
-------
mean : float | [
"Mean",
"of",
"non",
"-",
"NA",
"/",
"null",
"values"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L1549-L1566 | train |
pandas-dev/pandas | pandas/core/computation/expr.py | tokenize_string | def tokenize_string(source):
"""Tokenize a Python source code string.
Parameters
----------
source : str
A Python source code string
"""
line_reader = StringIO(source).readline
token_generator = tokenize.generate_tokens(line_reader)
# Loop over all tokens till a backtick (`) is... | python | def tokenize_string(source):
"""Tokenize a Python source code string.
Parameters
----------
source : str
A Python source code string
"""
line_reader = StringIO(source).readline
token_generator = tokenize.generate_tokens(line_reader)
# Loop over all tokens till a backtick (`) is... | [
"def",
"tokenize_string",
"(",
"source",
")",
":",
"line_reader",
"=",
"StringIO",
"(",
"source",
")",
".",
"readline",
"token_generator",
"=",
"tokenize",
".",
"generate_tokens",
"(",
"line_reader",
")",
"# Loop over all tokens till a backtick (`) is found.",
"# Then, ... | Tokenize a Python source code string.
Parameters
----------
source : str
A Python source code string | [
"Tokenize",
"a",
"Python",
"source",
"code",
"string",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/expr.py#L29-L49 | train |
pandas-dev/pandas | pandas/core/computation/expr.py | _replace_booleans | def _replace_booleans(tok):
"""Replace ``&`` with ``and`` and ``|`` with ``or`` so that bitwise
precedence is changed to boolean precedence.
Parameters
----------
tok : tuple of int, str
ints correspond to the all caps constants in the tokenize module
Returns
-------
t : tuple ... | python | def _replace_booleans(tok):
"""Replace ``&`` with ``and`` and ``|`` with ``or`` so that bitwise
precedence is changed to boolean precedence.
Parameters
----------
tok : tuple of int, str
ints correspond to the all caps constants in the tokenize module
Returns
-------
t : tuple ... | [
"def",
"_replace_booleans",
"(",
"tok",
")",
":",
"toknum",
",",
"tokval",
"=",
"tok",
"if",
"toknum",
"==",
"tokenize",
".",
"OP",
":",
"if",
"tokval",
"==",
"'&'",
":",
"return",
"tokenize",
".",
"NAME",
",",
"'and'",
"elif",
"tokval",
"==",
"'|'",
... | Replace ``&`` with ``and`` and ``|`` with ``or`` so that bitwise
precedence is changed to boolean precedence.
Parameters
----------
tok : tuple of int, str
ints correspond to the all caps constants in the tokenize module
Returns
-------
t : tuple of int, str
Either the inpu... | [
"Replace",
"&",
"with",
"and",
"and",
"|",
"with",
"or",
"so",
"that",
"bitwise",
"precedence",
"is",
"changed",
"to",
"boolean",
"precedence",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/expr.py#L70-L91 | train |
pandas-dev/pandas | pandas/core/computation/expr.py | _replace_locals | def _replace_locals(tok):
"""Replace local variables with a syntactically valid name.
Parameters
----------
tok : tuple of int, str
ints correspond to the all caps constants in the tokenize module
Returns
-------
t : tuple of int, str
Either the input or token or the replac... | python | def _replace_locals(tok):
"""Replace local variables with a syntactically valid name.
Parameters
----------
tok : tuple of int, str
ints correspond to the all caps constants in the tokenize module
Returns
-------
t : tuple of int, str
Either the input or token or the replac... | [
"def",
"_replace_locals",
"(",
"tok",
")",
":",
"toknum",
",",
"tokval",
"=",
"tok",
"if",
"toknum",
"==",
"tokenize",
".",
"OP",
"and",
"tokval",
"==",
"'@'",
":",
"return",
"tokenize",
".",
"OP",
",",
"_LOCAL_TAG",
"return",
"toknum",
",",
"tokval"
] | Replace local variables with a syntactically valid name.
Parameters
----------
tok : tuple of int, str
ints correspond to the all caps constants in the tokenize module
Returns
-------
t : tuple of int, str
Either the input or token or the replacement values
Notes
-----... | [
"Replace",
"local",
"variables",
"with",
"a",
"syntactically",
"valid",
"name",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/expr.py#L94-L116 | train |
pandas-dev/pandas | pandas/core/computation/expr.py | _clean_spaces_backtick_quoted_names | def _clean_spaces_backtick_quoted_names(tok):
"""Clean up a column name if surrounded by backticks.
Backtick quoted string are indicated by a certain tokval value. If a string
is a backtick quoted token it will processed by
:func:`_remove_spaces_column_name` so that the parser can find this
string ... | python | def _clean_spaces_backtick_quoted_names(tok):
"""Clean up a column name if surrounded by backticks.
Backtick quoted string are indicated by a certain tokval value. If a string
is a backtick quoted token it will processed by
:func:`_remove_spaces_column_name` so that the parser can find this
string ... | [
"def",
"_clean_spaces_backtick_quoted_names",
"(",
"tok",
")",
":",
"toknum",
",",
"tokval",
"=",
"tok",
"if",
"toknum",
"==",
"_BACKTICK_QUOTED_STRING",
":",
"return",
"tokenize",
".",
"NAME",
",",
"_remove_spaces_column_name",
"(",
"tokval",
")",
"return",
"tokn... | Clean up a column name if surrounded by backticks.
Backtick quoted string are indicated by a certain tokval value. If a string
is a backtick quoted token it will processed by
:func:`_remove_spaces_column_name` so that the parser can find this
string when the query is executed.
See also :meth:`NDFra... | [
"Clean",
"up",
"a",
"column",
"name",
"if",
"surrounded",
"by",
"backticks",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/expr.py#L119-L141 | train |
pandas-dev/pandas | pandas/core/computation/expr.py | _preparse | def _preparse(source, f=_compose(_replace_locals, _replace_booleans,
_rewrite_assign,
_clean_spaces_backtick_quoted_names)):
"""Compose a collection of tokenization functions
Parameters
----------
source : str
A Python source cod... | python | def _preparse(source, f=_compose(_replace_locals, _replace_booleans,
_rewrite_assign,
_clean_spaces_backtick_quoted_names)):
"""Compose a collection of tokenization functions
Parameters
----------
source : str
A Python source cod... | [
"def",
"_preparse",
"(",
"source",
",",
"f",
"=",
"_compose",
"(",
"_replace_locals",
",",
"_replace_booleans",
",",
"_rewrite_assign",
",",
"_clean_spaces_backtick_quoted_names",
")",
")",
":",
"assert",
"callable",
"(",
"f",
")",
",",
"'f must be callable'",
"re... | Compose a collection of tokenization functions
Parameters
----------
source : str
A Python source code string
f : callable
This takes a tuple of (toknum, tokval) as its argument and returns a
tuple with the same structure but possibly different elements. Defaults
to the ... | [
"Compose",
"a",
"collection",
"of",
"tokenization",
"functions"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/expr.py#L155-L182 | train |
pandas-dev/pandas | pandas/core/computation/expr.py | _filter_nodes | def _filter_nodes(superclass, all_nodes=_all_nodes):
"""Filter out AST nodes that are subclasses of ``superclass``."""
node_names = (node.__name__ for node in all_nodes
if issubclass(node, superclass))
return frozenset(node_names) | python | def _filter_nodes(superclass, all_nodes=_all_nodes):
"""Filter out AST nodes that are subclasses of ``superclass``."""
node_names = (node.__name__ for node in all_nodes
if issubclass(node, superclass))
return frozenset(node_names) | [
"def",
"_filter_nodes",
"(",
"superclass",
",",
"all_nodes",
"=",
"_all_nodes",
")",
":",
"node_names",
"=",
"(",
"node",
".",
"__name__",
"for",
"node",
"in",
"all_nodes",
"if",
"issubclass",
"(",
"node",
",",
"superclass",
")",
")",
"return",
"frozenset",
... | Filter out AST nodes that are subclasses of ``superclass``. | [
"Filter",
"out",
"AST",
"nodes",
"that",
"are",
"subclasses",
"of",
"superclass",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/expr.py#L200-L204 | train |
pandas-dev/pandas | pandas/core/computation/expr.py | _node_not_implemented | def _node_not_implemented(node_name, cls):
"""Return a function that raises a NotImplementedError with a passed node
name.
"""
def f(self, *args, **kwargs):
raise NotImplementedError("{name!r} nodes are not "
"implemented".format(name=node_name))
return f | python | def _node_not_implemented(node_name, cls):
"""Return a function that raises a NotImplementedError with a passed node
name.
"""
def f(self, *args, **kwargs):
raise NotImplementedError("{name!r} nodes are not "
"implemented".format(name=node_name))
return f | [
"def",
"_node_not_implemented",
"(",
"node_name",
",",
"cls",
")",
":",
"def",
"f",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"{name!r} nodes are not \"",
"\"implemented\"",
".",
"format",
"(",
"... | Return a function that raises a NotImplementedError with a passed node
name. | [
"Return",
"a",
"function",
"that",
"raises",
"a",
"NotImplementedError",
"with",
"a",
"passed",
"node",
"name",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/expr.py#L247-L255 | train |
pandas-dev/pandas | pandas/core/computation/expr.py | disallow | def disallow(nodes):
"""Decorator to disallow certain nodes from parsing. Raises a
NotImplementedError instead.
Returns
-------
disallowed : callable
"""
def disallowed(cls):
cls.unsupported_nodes = ()
for node in nodes:
new_method = _node_not_implemented(node, c... | python | def disallow(nodes):
"""Decorator to disallow certain nodes from parsing. Raises a
NotImplementedError instead.
Returns
-------
disallowed : callable
"""
def disallowed(cls):
cls.unsupported_nodes = ()
for node in nodes:
new_method = _node_not_implemented(node, c... | [
"def",
"disallow",
"(",
"nodes",
")",
":",
"def",
"disallowed",
"(",
"cls",
")",
":",
"cls",
".",
"unsupported_nodes",
"=",
"(",
")",
"for",
"node",
"in",
"nodes",
":",
"new_method",
"=",
"_node_not_implemented",
"(",
"node",
",",
"cls",
")",
"name",
"... | Decorator to disallow certain nodes from parsing. Raises a
NotImplementedError instead.
Returns
-------
disallowed : callable | [
"Decorator",
"to",
"disallow",
"certain",
"nodes",
"from",
"parsing",
".",
"Raises",
"a",
"NotImplementedError",
"instead",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/expr.py#L258-L274 | train |
pandas-dev/pandas | pandas/core/computation/expr.py | _op_maker | def _op_maker(op_class, op_symbol):
"""Return a function to create an op class with its symbol already passed.
Returns
-------
f : callable
"""
def f(self, node, *args, **kwargs):
"""Return a partial function with an Op subclass with an operator
already passed.
Returns... | python | def _op_maker(op_class, op_symbol):
"""Return a function to create an op class with its symbol already passed.
Returns
-------
f : callable
"""
def f(self, node, *args, **kwargs):
"""Return a partial function with an Op subclass with an operator
already passed.
Returns... | [
"def",
"_op_maker",
"(",
"op_class",
",",
"op_symbol",
")",
":",
"def",
"f",
"(",
"self",
",",
"node",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Return a partial function with an Op subclass with an operator\n already passed.\n\n Returns\... | Return a function to create an op class with its symbol already passed.
Returns
-------
f : callable | [
"Return",
"a",
"function",
"to",
"create",
"an",
"op",
"class",
"with",
"its",
"symbol",
"already",
"passed",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/expr.py#L277-L294 | train |
pandas-dev/pandas | pandas/core/computation/expr.py | add_ops | def add_ops(op_classes):
"""Decorator to add default implementation of ops."""
def f(cls):
for op_attr_name, op_class in op_classes.items():
ops = getattr(cls, '{name}_ops'.format(name=op_attr_name))
ops_map = getattr(cls, '{name}_op_nodes_map'.format(
name=op_att... | python | def add_ops(op_classes):
"""Decorator to add default implementation of ops."""
def f(cls):
for op_attr_name, op_class in op_classes.items():
ops = getattr(cls, '{name}_ops'.format(name=op_attr_name))
ops_map = getattr(cls, '{name}_op_nodes_map'.format(
name=op_att... | [
"def",
"add_ops",
"(",
"op_classes",
")",
":",
"def",
"f",
"(",
"cls",
")",
":",
"for",
"op_attr_name",
",",
"op_class",
"in",
"op_classes",
".",
"items",
"(",
")",
":",
"ops",
"=",
"getattr",
"(",
"cls",
",",
"'{name}_ops'",
".",
"format",
"(",
"nam... | Decorator to add default implementation of ops. | [
"Decorator",
"to",
"add",
"default",
"implementation",
"of",
"ops",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/expr.py#L300-L313 | train |
pandas-dev/pandas | pandas/core/computation/expr.py | Expr.names | def names(self):
"""Get the names in an expression"""
if is_term(self.terms):
return frozenset([self.terms.name])
return frozenset(term.name for term in com.flatten(self.terms)) | python | def names(self):
"""Get the names in an expression"""
if is_term(self.terms):
return frozenset([self.terms.name])
return frozenset(term.name for term in com.flatten(self.terms)) | [
"def",
"names",
"(",
"self",
")",
":",
"if",
"is_term",
"(",
"self",
".",
"terms",
")",
":",
"return",
"frozenset",
"(",
"[",
"self",
".",
"terms",
".",
"name",
"]",
")",
"return",
"frozenset",
"(",
"term",
".",
"name",
"for",
"term",
"in",
"com",
... | Get the names in an expression | [
"Get",
"the",
"names",
"in",
"an",
"expression"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/expr.py#L749-L753 | train |
pandas-dev/pandas | pandas/core/indexes/timedeltas.py | _is_convertible_to_index | def _is_convertible_to_index(other):
"""
return a boolean whether I can attempt conversion to a TimedeltaIndex
"""
if isinstance(other, TimedeltaIndex):
return True
elif (len(other) > 0 and
other.inferred_type not in ('floating', 'mixed-integer', 'integer',
... | python | def _is_convertible_to_index(other):
"""
return a boolean whether I can attempt conversion to a TimedeltaIndex
"""
if isinstance(other, TimedeltaIndex):
return True
elif (len(other) > 0 and
other.inferred_type not in ('floating', 'mixed-integer', 'integer',
... | [
"def",
"_is_convertible_to_index",
"(",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"TimedeltaIndex",
")",
":",
"return",
"True",
"elif",
"(",
"len",
"(",
"other",
")",
">",
"0",
"and",
"other",
".",
"inferred_type",
"not",
"in",
"(",
"'flo... | return a boolean whether I can attempt conversion to a TimedeltaIndex | [
"return",
"a",
"boolean",
"whether",
"I",
"can",
"attempt",
"conversion",
"to",
"a",
"TimedeltaIndex"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/timedeltas.py#L719-L729 | train |
pandas-dev/pandas | pandas/core/indexes/timedeltas.py | timedelta_range | def timedelta_range(start=None, end=None, periods=None, freq=None,
name=None, closed=None):
"""
Return a fixed frequency TimedeltaIndex, with day as the default
frequency
Parameters
----------
start : string or timedelta-like, default None
Left bound for generating t... | python | def timedelta_range(start=None, end=None, periods=None, freq=None,
name=None, closed=None):
"""
Return a fixed frequency TimedeltaIndex, with day as the default
frequency
Parameters
----------
start : string or timedelta-like, default None
Left bound for generating t... | [
"def",
"timedelta_range",
"(",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"periods",
"=",
"None",
",",
"freq",
"=",
"None",
",",
"name",
"=",
"None",
",",
"closed",
"=",
"None",
")",
":",
"if",
"freq",
"is",
"None",
"and",
"com",
".",
"_... | Return a fixed frequency TimedeltaIndex, with day as the default
frequency
Parameters
----------
start : string or timedelta-like, default None
Left bound for generating timedeltas
end : string or timedelta-like, default None
Right bound for generating timedeltas
periods : integ... | [
"Return",
"a",
"fixed",
"frequency",
"TimedeltaIndex",
"with",
"day",
"as",
"the",
"default",
"frequency"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/timedeltas.py#L732-L805 | train |
pandas-dev/pandas | pandas/core/indexes/frozen.py | FrozenList.union | def union(self, other):
"""
Returns a FrozenList with other concatenated to the end of self.
Parameters
----------
other : array-like
The array-like whose elements we are concatenating.
Returns
-------
diff : FrozenList
The collec... | python | def union(self, other):
"""
Returns a FrozenList with other concatenated to the end of self.
Parameters
----------
other : array-like
The array-like whose elements we are concatenating.
Returns
-------
diff : FrozenList
The collec... | [
"def",
"union",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"tuple",
")",
":",
"other",
"=",
"list",
"(",
"other",
")",
"return",
"type",
"(",
"self",
")",
"(",
"super",
"(",
")",
".",
"__add__",
"(",
"other",
")",... | Returns a FrozenList with other concatenated to the end of self.
Parameters
----------
other : array-like
The array-like whose elements we are concatenating.
Returns
-------
diff : FrozenList
The collection difference between self and other. | [
"Returns",
"a",
"FrozenList",
"with",
"other",
"concatenated",
"to",
"the",
"end",
"of",
"self",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/frozen.py#L34-L50 | train |
pandas-dev/pandas | pandas/core/indexes/frozen.py | FrozenList.difference | def difference(self, other):
"""
Returns a FrozenList with elements from other removed from self.
Parameters
----------
other : array-like
The array-like whose elements we are removing self.
Returns
-------
diff : FrozenList
The c... | python | def difference(self, other):
"""
Returns a FrozenList with elements from other removed from self.
Parameters
----------
other : array-like
The array-like whose elements we are removing self.
Returns
-------
diff : FrozenList
The c... | [
"def",
"difference",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"set",
"(",
"other",
")",
"temp",
"=",
"[",
"x",
"for",
"x",
"in",
"self",
"if",
"x",
"not",
"in",
"other",
"]",
"return",
"type",
"(",
"self",
")",
"(",
"temp",
")"
] | Returns a FrozenList with elements from other removed from self.
Parameters
----------
other : array-like
The array-like whose elements we are removing self.
Returns
-------
diff : FrozenList
The collection difference between self and other. | [
"Returns",
"a",
"FrozenList",
"with",
"elements",
"from",
"other",
"removed",
"from",
"self",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/frozen.py#L52-L68 | train |
pandas-dev/pandas | pandas/core/indexes/frozen.py | FrozenNDArray.searchsorted | def searchsorted(self, value, side="left", sorter=None):
"""
Find indices to insert `value` so as to maintain order.
For full documentation, see `numpy.searchsorted`
See Also
--------
numpy.searchsorted : Equivalent function.
"""
# We are much more perf... | python | def searchsorted(self, value, side="left", sorter=None):
"""
Find indices to insert `value` so as to maintain order.
For full documentation, see `numpy.searchsorted`
See Also
--------
numpy.searchsorted : Equivalent function.
"""
# We are much more perf... | [
"def",
"searchsorted",
"(",
"self",
",",
"value",
",",
"side",
"=",
"\"left\"",
",",
"sorter",
"=",
"None",
")",
":",
"# We are much more performant if the searched",
"# indexer is the same type as the array.",
"#",
"# This doesn't matter for int64, but DOES",
"# matter for s... | Find indices to insert `value` so as to maintain order.
For full documentation, see `numpy.searchsorted`
See Also
--------
numpy.searchsorted : Equivalent function. | [
"Find",
"indices",
"to",
"insert",
"value",
"so",
"as",
"to",
"maintain",
"order",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/frozen.py#L161-L184 | train |
pandas-dev/pandas | pandas/core/internals/construction.py | arrays_to_mgr | def arrays_to_mgr(arrays, arr_names, index, columns, dtype=None):
"""
Segregate Series based on type and coerce into matrices.
Needs to handle a lot of exceptional cases.
"""
# figure out the index, if necessary
if index is None:
index = extract_index(arrays)
else:
index = e... | python | def arrays_to_mgr(arrays, arr_names, index, columns, dtype=None):
"""
Segregate Series based on type and coerce into matrices.
Needs to handle a lot of exceptional cases.
"""
# figure out the index, if necessary
if index is None:
index = extract_index(arrays)
else:
index = e... | [
"def",
"arrays_to_mgr",
"(",
"arrays",
",",
"arr_names",
",",
"index",
",",
"columns",
",",
"dtype",
"=",
"None",
")",
":",
"# figure out the index, if necessary",
"if",
"index",
"is",
"None",
":",
"index",
"=",
"extract_index",
"(",
"arrays",
")",
"else",
"... | Segregate Series based on type and coerce into matrices.
Needs to handle a lot of exceptional cases. | [
"Segregate",
"Series",
"based",
"on",
"type",
"and",
"coerce",
"into",
"matrices",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/construction.py#L41-L59 | train |
pandas-dev/pandas | pandas/core/internals/construction.py | masked_rec_array_to_mgr | 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... | python | 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",
")",
":",
"# essentially process a record array then fill it",
"fill_value",
"=",
"data",
".",
"fill_value",
"fdata",
"=",
"ma",
".",
"getdata",
"(",
"data",
... | Extract from a masked rec array and create the manager. | [
"Extract",
"from",
"a",
"masked",
"rec",
"array",
"and",
"create",
"the",
"manager",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/construction.py#L62-L98 | train |
pandas-dev/pandas | pandas/core/internals/construction.py | init_dict | 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_... | python | 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",
")",
":",
"if",
"columns",
"is",
"not",
"None",
":",
"from",
"pandas",
".",
"core",
".",
"series",
"import",
"Series",
"arrays",
"=",
"Series",
"(",
"data",
","... | Segregate Series based on type and coerce into matrices.
Needs to handle a lot of exceptional cases. | [
"Segregate",
"Series",
"based",
"on",
"type",
"and",
"coerce",
"into",
"matrices",
".",
"Needs",
"to",
"handle",
"a",
"lot",
"of",
"exceptional",
"cases",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/construction.py#L168-L204 | train |
pandas-dev/pandas | pandas/core/internals/construction.py | to_arrays | 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]
... | python | 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",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"ABCDataFrame",
")",
":",
"if",
"columns",
"is",
"not",
"None",
":",
"arrays",
"=",
"[",
"d... | Return list of arrays, columns. | [
"Return",
"list",
"of",
"arrays",
"columns",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/construction.py#L374-L418 | train |
pandas-dev/pandas | pandas/core/internals/construction.py | sanitize_index | 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... | python | 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",
")",
":",
"if",
"index",
"is",
"None",
":",
"return",
"data",
"if",
"len",
"(",
"data",
")",
"!=",
"len",
"(",
"index",
")",
":",
"raise",
"ValueError",
"(",
"'Length of v... | Sanitize an index type to return an ndarray of the underlying, pass
through a non-Index. | [
"Sanitize",
"an",
"index",
"type",
"to",
"return",
"an",
"ndarray",
"of",
"the",
"underlying",
"pass",
"through",
"a",
"non",
"-",
"Index",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/construction.py#L501-L526 | train |
pandas-dev/pandas | pandas/core/internals/construction.py | sanitize_array | 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):
... | python | 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",
")",
":",
"if",
"dtype",
"is",
"not",
"None",
":",
"dtype",
"=",
"pandas_dtype",
"(",
"dtype",
")",
"if",... | Sanitize input data to an ndarray, copy if specified, coerce to the
dtype if specified. | [
"Sanitize",
"input",
"data",
"to",
"an",
"ndarray",
"copy",
"if",
"specified",
"coerce",
"to",
"the",
"dtype",
"if",
"specified",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/construction.py#L529-L672 | train |
pandas-dev/pandas | pandas/core/computation/eval.py | _check_engine | 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... | python | 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",
")",
":",
"from",
"pandas",
".",
"core",
".",
"computation",
".",
"check",
"import",
"_NUMEXPR_INSTALLED",
"if",
"engine",
"is",
"None",
":",
"if",
"_NUMEXPR_INSTALLED",
":",
"engine",
"=",
"'numexpr'",
"else",
":",
"en... | 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 | [
"Make",
"sure",
"a",
"valid",
"engine",
"is",
"passed",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/eval.py#L17-L59 | train |
pandas-dev/pandas | pandas/core/computation/eval.py | _check_parser | 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... | python | 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",
")",
":",
"from",
"pandas",
".",
"core",
".",
"computation",
".",
"expr",
"import",
"_parsers",
"if",
"parser",
"not",
"in",
"_parsers",
":",
"raise",
"KeyError",
"(",
"'Invalid parser {parser!r} passed, valid parsers are'",
... | Make sure a valid parser is passed.
Parameters
----------
parser : str
Raises
------
KeyError
* If an invalid parser is passed | [
"Make",
"sure",
"a",
"valid",
"parser",
"is",
"passed",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/eval.py#L62-L78 | train |
pandas-dev/pandas | pandas/core/computation/eval.py | eval | 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: ``+``, ``-``, ``*``,
``/... | python | 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",
",",
"tar... | 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'`... | [
"Evaluate",
"a",
"Python",
"expression",
"as",
"a",
"string",
"using",
"various",
"backends",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/eval.py#L155-L350 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndexUIntEngine._codes_to_ints | 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 :... | python | 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",
")",
":",
"# 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... | 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
... | [
"Transform",
"combination",
"(",
"s",
")",
"of",
"uint64",
"in",
"one",
"uint64",
"(",
"each",
")",
"in",
"a",
"strictly",
"monotonic",
"way",
"(",
"i",
".",
"e",
".",
"respecting",
"the",
"lexicographic",
"order",
"of",
"integer",
"combinations",
")",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L49-L77 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.from_arrays | 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.
... | python | 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",
")",
":",
"error_msg",
"=",
"\"Input must be a list / sequence of array-likes.\"",
"if",
"not",
"is_list_like",
"(",
"arrays",
")",
":",
"raise",
"TypeErro... | 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... | [
"Convert",
"arrays",
"to",
"MultiIndex",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L292-L350 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.from_tuples | 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... | python | 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",
")",
":",
"if",
"not",
"is_list_like",
"(",
"tuples",
")",
":",
"raise",
"TypeError",
"(",
"'Input must be a list / sequence of tuple-likes.'",
")",
"eli... | 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 ... | [
"Convert",
"list",
"of",
"tuples",
"to",
"MultiIndex",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L353-L407 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.from_product | 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... | python | 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",
")",
":",
"from",
"pandas",
".",
"core",
".",
"arrays",
".",
"categorical",
"import",
"_factorize_from_iterables",
"from",
"pandas",
".",
"core",
... | 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 ... | [
"Make",
"a",
"MultiIndex",
"from",
"the",
"cartesian",
"product",
"of",
"multiple",
"iterables",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L410-L454 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.from_frame | 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... | python | 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",
")",
":",
"if",
"not",
"isinstance",
"(",
"df",
",",
"ABCDataFrame",
")",
":",
"raise",
"TypeError",
"(",
"\"Input must be a DataFrame\"",
")",
"column_na... | 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).
... | [
"Make",
"a",
"MultiIndex",
"from",
"a",
"DataFrame",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L457-L516 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.set_levels | 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... | python | 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",
")",
":",
"if",
"is_list_like",
"(",
"levels",
")",
"and",
"not",
"isinstance",
"(",
"levels",
",",
"Index",
... | 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)
... | [
"Set",
"new",
"levels",
"on",
"MultiIndex",
".",
"Defaults",
"to",
"returning",
"new",
"index",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L599-L664 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.set_codes | 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
----------
... | python | 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",
")",
":",
"if",
"level",
"is",
"not",
"None",
"and",
"not",
"is_list_like",
"(",
"level",
")",
":",
"if",
"n... | 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... | [
"Set",
"new",
"codes",
"on",
"MultiIndex",
".",
"Defaults",
"to",
"returning",
"new",
"index",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L714-L779 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.copy | 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... | python | 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",
")",
":",
"name",
"="... | 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... | [
"Make",
"a",
"copy",
"of",
"this",
"object",
".",
"Names",
"dtype",
"levels",
"and",
"codes",
"can",
"be",
"passed",
"and",
"will",
"be",
"set",
"on",
"new",
"copy",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L782-L821 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.view | def view(self, cls=None):
""" this is defined as a copy with the same identity """
result = self.copy()
result._id = self._id
return result | python | 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",
")",
":",
"result",
"=",
"self",
".",
"copy",
"(",
")",
"result",
".",
"_id",
"=",
"self",
".",
"_id",
"return",
"result"
] | this is defined as a copy with the same identity | [
"this",
"is",
"defined",
"as",
"a",
"copy",
"with",
"the",
"same",
"identity"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L827-L831 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex._is_memory_usage_qualified | 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) | python | 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",
")",
":",
"def",
"f",
"(",
"l",
")",
":",
"return",
"'mixed'",
"in",
"l",
"or",
"'string'",
"in",
"l",
"or",
"'unicode'",
"in",
"l",
"return",
"any",
"(",
"f",
"(",
"l",
")",
"for",
"l",
"in",
"self... | return a boolean if we need a qualified .info display | [
"return",
"a",
"boolean",
"if",
"we",
"need",
"a",
"qualified",
".",
"info",
"display"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L866-L870 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex._nbytes | 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... | python | 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",
")",
":",
"# for implementations with no useful getsizeof (PyPy)",
"objsize",
"=",
"24",
"level_nbytes",
"=",
"sum",
"(",
"i",
".",
"memory_usage",
"(",
"deep",
"=",
"deep",
")",
"for",
"i",
"in",
"se... | 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* | [
"return",
"the",
"number",
"of",
"bytes",
"in",
"the",
"underlying",
"data",
"deeply",
"introspect",
"the",
"level",
"data",
"if",
"deep",
"=",
"True"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L884-L905 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex._format_attrs | 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,
... | python | 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",
")",
":",
"attrs",
"=",
"[",
"(",
"'levels'",
",",
"ibase",
".",
"default_pprint",
"(",
"self",
".",
"_levels",
",",
"max_seq_items",
"=",
"False",
")",
")",
",",
"(",
"'codes'",
",",
"ibase",
".",
"default_pprint",
... | Return a list of tuples of the (attr,formatted_value) | [
"Return",
"a",
"list",
"of",
"tuples",
"of",
"the",
"(",
"attr",
"formatted_value",
")"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L910-L923 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex._set_names | 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)
... | python | 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",
")",
":",
"# GH 15110",
"# Don't allow a single string for names in a MultiIndex",
"if",
"names",
"is",
"not",
"None",
"and",
"not",
"is_list_like",
"(",
"na... | 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
... | [
"Set",
"new",
"names",
"on",
"index",
".",
"Each",
"name",
"has",
"to",
"be",
"a",
"hashable",
"type",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1026-L1076 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.is_monotonic_increasing | 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... | python | 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",
")",
":",
"# reversed() because lexsort() wants the most significant key last.",
"values",
"=",
"[",
"self",
".",
"_get_level_values",
"(",
"i",
")",
".",
"values",
"for",
"i",
"in",
"reversed",
"(",
"range",
"(",
"len"... | return if the index is monotonic increasing (only equal or
increasing) values. | [
"return",
"if",
"the",
"index",
"is",
"monotonic",
"increasing",
"(",
"only",
"equal",
"or",
"increasing",
")",
"values",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1192-L1207 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex._hashed_indexing_key | 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
-----
... | python | 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",
")",
":",
"from",
"pandas",
".",
"core",
".",
"util",
".",
"hashing",
"import",
"hash_tuples",
",",
"hash_tuple",
"if",
"not",
"isinstance",
"(",
"key",
",",
"tuple",
")",
":",
"return",
"hash_tuples"... | 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 | [
"validate",
"and",
"return",
"the",
"hash",
"for",
"the",
"provided",
"key"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1234-L1267 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex._get_level_values | 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... | python | 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",
")",
":",
"values",
"=",
"self",
".",
"levels",
"[",
"level",
"]",
"level_codes",
"=",
"self",
".",
"codes",
"[",
"level",
"]",
"if",
"unique",
":",
"level_codes",
"=",... | 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... | [
"Return",
"vector",
"of",
"label",
"values",
"for",
"requested",
"level",
"equal",
"to",
"the",
"length",
"of",
"the",
"index"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1357-L1382 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.get_level_values | 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... | python | 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",
")",
":",
"level",
"=",
"self",
".",
"_get_level_number",
"(",
"level",
")",
"values",
"=",
"self",
".",
"_get_level_values",
"(",
"level",
")",
"return",
"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
-------
... | [
"Return",
"vector",
"of",
"label",
"values",
"for",
"requested",
"level",
"equal",
"to",
"the",
"length",
"of",
"the",
"index",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1384-L1418 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.to_frame | 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... | python | 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",
")",
":",
"from",
"pandas",
"import",
"DataFrame",
"if",
"name",
"is",
"not",
"None",
":",
"if",
"not",
"is_list_like",
"(",
"name",
")",
":",
"raise",
"TypeError",
... | 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... | [
"Create",
"a",
"DataFrame",
"with",
"the",
"levels",
"of",
"the",
"MultiIndex",
"as",
"columns",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1433-L1484 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.to_hierarchical | 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.
... | python | 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",
")",
":",
"levels",
"=",
"self",
".",
"levels",
"codes",
"=",
"[",
"np",
".",
"repeat",
"(",
"level_codes",
",",
"n_repeat",
")",
"for",
"level_codes",
"in",
"self",
".... | 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
... | [
"Return",
"a",
"MultiIndex",
"reshaped",
"to",
"conform",
"to",
"the",
"shapes",
"given",
"by",
"n_repeat",
"and",
"n_shuffle",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1486-L1528 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex._sort_levels_monotonic | 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... | python | 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",
")",
":",
"if",
"self",
".",
"is_lexsorted",
"(",
")",
"and",
"self",
".",
"is_monotonic",
":",
"return",
"self",
"new_levels",
"=",
"[",
"]",
"new_codes",
"=",
"[",
"]",
"for",
"lev",
",",
"level_codes",
"in... | .. 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
... | [
"..",
"versionadded",
"::",
"0",
".",
"20",
".",
"0"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1583-L1643 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.remove_unused_levels | 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
... | python | 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",
")",
":",
"new_levels",
"=",
"[",
"]",
"new_codes",
"=",
"[",
"]",
"changed",
"=",
"False",
"for",
"lev",
",",
"level_codes",
"in",
"zip",
"(",
"self",
".",
"levels",
",",
"self",
".",
"codes",
")",
":",
"#... | 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... | [
"Create",
"a",
"new",
"MultiIndex",
"from",
"the",
"current",
"that",
"removes",
"unused",
"levels",
"meaning",
"that",
"they",
"are",
"not",
"expressed",
"in",
"the",
"labels",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1645-L1725 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex._assert_take_fillable | 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... | python | 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",
")",
":",
"# only fill if we are passing a non-None fill_value",
"if",
"allow_fill",
"and",
"f... | Internal method to handle NA filling of take | [
"Internal",
"method",
"to",
"handle",
"NA",
"filling",
"of",
"take"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1806-L1826 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.append | 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... | python | 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",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"other",
"=",
"[",
"other",
"]",
"if",
"all",
"(",
"(",
"isinstance",
"(",
"o",
",",
"MultiIndex",
")",
... | Append a collection of Index options together
Parameters
----------
other : Index or list/tuple of indices
Returns
-------
appended : Index | [
"Append",
"a",
"collection",
"of",
"Index",
"options",
"together"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1828-L1859 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.drop | 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... | python | 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'",
")",
":",
"if",
"level",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_drop_from_level",
"(",
"codes",
",",
"level",
")",
"try",
":",
"if",
"no... | 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 | [
"Make",
"new",
"MultiIndex",
"with",
"passed",
"list",
"of",
"codes",
"deleted"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1878-L1933 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.swaplevel | 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... | python | 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",
")",
":",
"new_levels",
"=",
"list",
"(",
"self",
".",
"levels",
")",
"new_codes",
"=",
"list",
"(",
"self",
".",
"codes",
")",
"new_names",
"=",
"list",
"(",
"s... | 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... | [
"Swap",
"level",
"i",
"with",
"level",
"j",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1945-L1999 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.reorder_levels | 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... | python | 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",
")",
":",
"order",
"=",
"[",
"self",
".",
"_get_level_number",
"(",
"i",
")",
"for",
"i",
"in",
"order",
"]",
"if",
"len",
"(",
"order",
")",
"!=",
"self",
".",
"nlevels",
":",
"raise",
"AssertionEr... | Rearrange levels using input order. May not drop or duplicate levels
Parameters
---------- | [
"Rearrange",
"levels",
"using",
"input",
"order",
".",
"May",
"not",
"drop",
"or",
"duplicate",
"levels"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2001-L2018 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex._get_codes_for_sorting | 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... | python | 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",
")",
":",
"from",
"pandas",
".",
"core",
".",
"arrays",
"import",
"Categorical",
"def",
"cats",
"(",
"level_codes",
")",
":",
"return",
"np",
".",
"arange",
"(",
"np",
".",
"array",
"(",
"level_codes",
")",
"... | 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 | [
"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",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2023-L2040 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.sortlevel | 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
... | python | 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",
")",
":",
"from",
"pandas",
".",
"core",
".",
"sorting",
"import",
"indexer_from_factorized",
"if",
"isinstance",
"(",
"level",
",",... | 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... | [
"Sort",
"MultiIndex",
"at",
"the",
"requested",
"level",
".",
"The",
"result",
"will",
"respect",
"the",
"original",
"ordering",
"of",
"the",
"associated",
"factor",
"at",
"that",
"level",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2042-L2115 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex._convert_listlike_indexer | 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... | python | 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",
")",
":",
"indexer",
",",
"keyarr",
"=",
"super",
"(",
")",
".",
"_convert_listlike_indexer",
"(",
"keyarr",
",",
"kind",
"=",
"kind",
")",
"# are we indexing a specific ... | 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 | [
"Parameters",
"----------",
"keyarr",
":",
"list",
"-",
"like",
"Indexer",
"to",
"convert",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2117-L2147 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.reindex | 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
... | python | 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",
")",
":",
"# GH6552: preserve names when reindexing to non-named target",
"# (i.e. neither Index nor Series... | 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. | [
"Create",
"index",
"with",
"target",
"s",
"values",
"(",
"move",
"/",
"add",
"/",
"delete",
"values",
"as",
"necessary",
")"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2191-L2252 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.slice_locs | 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... | python | 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",
")",
":",
"# This function adds nothing to its parent implementation (the magic",
"# happens in get_slice_bound method), but it adds... | 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
... | [
"For",
"an",
"ordered",
"MultiIndex",
"compute",
"the",
"slice",
"locations",
"for",
"input",
"labels",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2260-L2314 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.get_loc | 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... | python | 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",
")",
":",
"if",
"method",
"is",
"not",
"None",
":",
"raise",
"NotImplementedError",
"(",
"'only the default get_loc method is '",
"'currently supported for MultiIndex'",
")",
"def",
"_maybe_to_sl... | 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 ... | [
"Get",
"location",
"for",
"a",
"label",
"or",
"a",
"tuple",
"of",
"labels",
"as",
"an",
"integer",
"slice",
"or",
"boolean",
"mask",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2347-L2445 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.get_loc_level | 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... | python | 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",
")",
":",
"def",
"maybe_droplevels",
"(",
"indexer",
",",
"levels",
",",
"drop_level",
")",
":",
"if",
"not",
"drop_level",
":",
"return",
"self",
... | 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... | [
"Get",
"both",
"the",
"location",
"for",
"the",
"requested",
"label",
"(",
"s",
")",
"and",
"the",
"resulting",
"sliced",
"index",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2447-L2581 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.get_locs | 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... | python | 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",
")",
":",
"from",
".",
"numeric",
"import",
"Int64Index",
"# must be lexsorted to at least as many levels",
"true_slices",
"=",
"[",
"i",
"for",
"(",
"i",
",",
"s",
")",
"in",
"enumerate",
"(",
"com",
".",
"is_true... | 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... | [
"Get",
"location",
"for",
"a",
"given",
"label",
"/",
"slice",
"/",
"list",
"/",
"mask",
"or",
"a",
"sequence",
"of",
"such",
"as",
"an",
"array",
"of",
"integers",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2678-L2796 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.truncate | 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 ... | python | 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",
")",
":",
"if",
"after",
"and",
"before",
"and",
"after",
"<",
"before",
":",
"raise",
"ValueError",
"(",
"'after < before'",
")",
"i",
",",
"j",
"=",
"self",
".",... | 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
--... | [
"Slice",
"index",
"between",
"two",
"labels",
"/",
"tuples",
"return",
"new",
"MultiIndex"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2798-L2826 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.equals | 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 ... | python | 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",
")",
":",
"if",
"self",
".",
"is_",
"(",
"other",
")",
":",
"return",
"True",
"if",
"not",
"isinstance",
"(",
"other",
",",
"Index",
")",
":",
"return",
"False",
"if",
"not",
"isinstance",
"(",
"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 | [
"Determines",
"if",
"two",
"MultiIndex",
"objects",
"have",
"the",
"same",
"labeling",
"information",
"(",
"the",
"levels",
"themselves",
"do",
"not",
"necessarily",
"have",
"to",
"be",
"the",
"same",
")"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2828-L2876 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.equal_levels | 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... | python | 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",
")",
":",
"if",
"self",
".",
"nlevels",
"!=",
"other",
".",
"nlevels",
":",
"return",
"False",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"nlevels",
")",
":",
"if",
"not",
"self",
".",
"levels",
"... | Return True if the levels of both MultiIndex objects are the same | [
"Return",
"True",
"if",
"the",
"levels",
"of",
"both",
"MultiIndex",
"objects",
"are",
"the",
"same"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2878-L2889 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.union | 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, ... | python | 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",
")",
":",
"self",
".",
"_validate_sort_keyword",
"(",
"sort",
")",
"self",
".",
"_assert_can_do_setop",
"(",
"other",
")",
"other",
",",
"result_names",
"=",
"self",
".",
"_convert_can_do... | 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... | [
"Form",
"the",
"union",
"of",
"two",
"MultiIndex",
"objects"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2891-L2937 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.intersection | 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... | python | 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",
")",
":",
"self",
".",
"_validate_sort_keyword",
"(",
"sort",
")",
"self",
".",
"_assert_can_do_setop",
"(",
"other",
")",
"other",
",",
"result_names",
"=",
"self",
".",
"_conver... | 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
... | [
"Form",
"the",
"intersection",
"of",
"two",
"MultiIndex",
"objects",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2939-L2980 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.difference | 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
... | python | 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",
")",
":",
"self",
".",
"_validate_sort_keyword",
"(",
"sort",
")",
"self",
".",
"_assert_can_do_setop",
"(",
"other",
")",
"other",
",",
"result_names",
"=",
"self",
".",
"_convert_c... | 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... | [
"Compute",
"set",
"difference",
"of",
"two",
"MultiIndex",
"objects"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L2982-L3032 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.insert | 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
"""
... | python | 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",
")",
":",
"# Pad the key with empty strings if lower levels of the key",
"# aren't specified:",
"if",
"not",
"isinstance",
"(",
"item",
",",
"tuple",
")",
":",
"item",
"=",
"(",
"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"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L3066-L3105 | train |
pandas-dev/pandas | pandas/core/indexes/multi.py | MultiIndex.delete | 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,
... | python | 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",
")",
":",
"new_codes",
"=",
"[",
"np",
".",
"delete",
"(",
"level_codes",
",",
"loc",
")",
"for",
"level_codes",
"in",
"self",
".",
"codes",
"]",
"return",
"MultiIndex",
"(",
"levels",
"=",
"self",
".",
"leve... | Make new index with passed location deleted
Returns
-------
new_index : MultiIndex | [
"Make",
"new",
"index",
"with",
"passed",
"location",
"deleted"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L3107-L3117 | train |
pandas-dev/pandas | pandas/core/algorithms.py | _ensure_data | 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)
... | python | 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",
")",
":",
"# we check some simple dtypes first",
"try",
":",
"if",
"is_object_dtype",
"(",
"dtype",
")",
":",
"return",
"ensure_object",
"(",
"np",
".",
"asarray",
"(",
"values",
")",
")",
",",... | 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
-----... | [
"routine",
"to",
"ensure",
"that",
"our",
"data",
"is",
"of",
"the",
"correct",
"input",
"dtype",
"for",
"lower",
"-",
"level",
"routines"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L36-L127 | train |
pandas-dev/pandas | pandas/core/algorithms.py | _reconstruct_data | 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
... | python | 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",
")",
":",
"from",
"pandas",
"import",
"Index",
"if",
"is_extension_array_dtype",
"(",
"dtype",
")",
":",
"values",
"=",
"dtype",
".",
"construct_array_type",
"(",
")",
".",
"_from_sequen... | reverse of _ensure_data
Parameters
----------
values : ndarray
dtype : pandas_dtype
original : ndarray-like
Returns
-------
Index for extension types, otherwise ndarray casted to dtype | [
"reverse",
"of",
"_ensure_data"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L130-L158 | train |
pandas-dev/pandas | pandas/core/algorithms.py | _ensure_arraylike | 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)... | python | 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",
")",
":",
"if",
"not",
"is_array_like",
"(",
"values",
")",
":",
"inferred",
"=",
"lib",
".",
"infer_dtype",
"(",
"values",
",",
"skipna",
"=",
"False",
")",
"if",
"inferred",
"in",
"[",
"'mixed'",
",",
"'string... | ensure that we are arraylike if not already | [
"ensure",
"that",
"we",
"are",
"arraylike",
"if",
"not",
"already"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L161-L173 | train |
pandas-dev/pandas | pandas/core/algorithms.py | _get_hashtable_algo | 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':
... | python | 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",
")",
":",
"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... | Parameters
----------
values : arraylike
Returns
-------
tuples(hashtable class,
vector class,
values,
dtype,
ndtype) | [
"Parameters",
"----------",
"values",
":",
"arraylike"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L185-L212 | train |
pandas-dev/pandas | pandas/core/algorithms.py | match | 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... | python | 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",
")",
":",
"values",
"=",
"com",
".",
"asarray_tuplesafe",
"(",
"values",
")",
"htable",
",",
"_",
",",
"values",
",",
"dtype",
",",
"ndtype",
"=",
"_get_hashtable_algo",
... | 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 : ... | [
"Compute",
"locations",
"of",
"to_match",
"into",
"values"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L238-L273 | train |
pandas-dev/pandas | pandas/core/algorithms.py | unique | 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... | python | 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",
")",
":",
"values",
"=",
"_ensure_arraylike",
"(",
"values",
")",
"if",
"is_extension_array_dtype",
"(",
"values",
")",
":",
"# Dispatch to extension dtype's unique.",
"return",
"values",
".",
"unique",
"(",
")",
"original",
"=",
... | 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... | [
"Hash",
"table",
"-",
"based",
"unique",
".",
"Uniques",
"are",
"returned",
"in",
"order",
"of",
"appearance",
".",
"This",
"does",
"NOT",
"sort",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L276-L367 | train |
pandas-dev/pandas | pandas/core/algorithms.py | isin | 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... | python | 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",
")",
":",
"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",
... | Compute the isin boolean array
Parameters
----------
comps : array-like
values : array-like
Returns
-------
boolean array same length as comps | [
"Compute",
"the",
"isin",
"boolean",
"array"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L373-L434 | train |
pandas-dev/pandas | pandas/core/algorithms.py | _factorize_array | 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... | python | 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",
")",
":",
"(",
"hash_klass",
",",
"_",
")",
",",
"values",
"=",
"_get_data_algo",
"(",
"values",
",",
"_hashtables",... | 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... | [
"Factorize",
"an",
"array",
"-",
"like",
"to",
"labels",
"and",
"uniques",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L437-L466 | train |
pandas-dev/pandas | pandas/core/algorithms.py | value_counts | 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... | python | 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",
")",
":",
"from",
"pandas",
".",
"core",
".",
"series",
"import",
"S... | 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... | [
"Compute",
"a",
"histogram",
"of",
"the",
"counts",
"of",
"non",
"-",
"null",
"values",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L649-L720 | train |
pandas-dev/pandas | pandas/core/algorithms.py | _value_counts_arraylike | 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... | python | 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",
")",
":",
"values",
"=",
"_ensure_arraylike",
"(",
"values",
")",
"original",
"=",
"values",
"values",
",",
"dtype",
",",
"ndtype",
"=",
"_ensure_data",
"(",
"values",
")",
"if",
"needs_i8_convers... | Parameters
----------
values : arraylike
dropna : boolean
Returns
-------
(uniques, counts) | [
"Parameters",
"----------",
"values",
":",
"arraylike",
"dropna",
":",
"boolean"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L723-L763 | train |
pandas-dev/pandas | pandas/core/algorithms.py | duplicated | 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... | python | 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'",
")",
":",
"values",
",",
"dtype",
",",
"ndtype",
"=",
"_ensure_data",
"(",
"values",
")",
"f",
"=",
"getattr",
"(",
"htable",
",",
"\"duplicated_{dtype}\"",
".",
"format",
"(",
"dtype",
"="... | 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
... | [
"Return",
"boolean",
"ndarray",
"denoting",
"duplicate",
"values",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L766-L790 | train |
pandas-dev/pandas | pandas/core/algorithms.py | mode | 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
-----... | python | 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",
")",
":",
"from",
"pandas",
"import",
"Series",
"values",
"=",
"_ensure_arraylike",
"(",
"values",
")",
"original",
"=",
"values",
"# categorical is a fast-path",
"if",
"is_categorical_dtype",
"(",
"value... | 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 | [
"Returns",
"the",
"mode",
"(",
"s",
")",
"of",
"an",
"array",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L793-L835 | train |
pandas-dev/pandas | pandas/core/algorithms.py | rank | 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 :... | python | 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",
")",
":",
"if",
"values",
".",
"ndim",
"==",
"1",
":",
"f",
",",
"valu... | 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', '... | [
"Rank",
"the",
"values",
"along",
"a",
"given",
"axis",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L838-L874 | train |
pandas-dev/pandas | pandas/core/algorithms.py | checked_add_with_arr | 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... | python | 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",
")",
":",
"# For performance reasons, we broadcast 'b' to the new array 'b2'",
"# so that it has the same size as 'arr'.",
"b2",
"=",
"np",
".",
"broadcast_to",
... | 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... | [
"Perform",
"array",
"addition",
"that",
"checks",
"for",
"underflow",
"and",
"overflow",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L877-L948 | train |
pandas-dev/pandas | pandas/core/algorithms.py | quantile | 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... | python | 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'",
")",
":",
"x",
"=",
"np",
".",
"asarray",
"(",
"x",
")",
"mask",
"=",
"isna",
"(",
"x",
")",
"x",
"=",
"x",
"[",
"~",
"mask",
"]",
"values",
"=",
"np",
".",
... | 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... | [
"Compute",
"sample",
"quantile",
"or",
"quantiles",
"of",
"the",
"input",
"array",
".",
"For",
"example",
"q",
"=",
"0",
".",
"5",
"computes",
"the",
"median",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L966-L1043 | train |
pandas-dev/pandas | pandas/core/algorithms.py | take | 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... | python | 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",
")",
":",
"from",
"pandas",
".",
"core",
".",
"indexing",
"import",
"validate_indices",
"if",
"not",
"is_array_like",
"(",
... | 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... | [
"Take",
"elements",
"from",
"an",
"array",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L1457-L1548 | train |
pandas-dev/pandas | pandas/core/algorithms.py | take_nd | 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``.
... | python | 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",
")",
":",
"# TODO(EA): Remove these if / elifs as datetim... | 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... | [
"Specialized",
"Cython",
"take",
"which",
"sets",
"NaN",
"values",
"in",
"one",
"pass"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L1551-L1666 | train |
pandas-dev/pandas | pandas/core/algorithms.py | take_2d_multi | 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)
... | python | 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",
")",
":",
"if",
"indexer",
"is",
"None",
"or",
"(",
"indexer",
"[",
... | Specialized Cython take which sets NaN values in one pass | [
"Specialized",
"Cython",
"take",
"which",
"sets",
"NaN",
"values",
"in",
"one",
"pass"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L1672-L1737 | train |
pandas-dev/pandas | pandas/core/algorithms.py | searchsorted | 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 ... | python | 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",
")",
":",
"if",
"sorter",
"is",
"not",
"None",
":",
"sorter",
"=",
"ensure_platform_int",
"(",
"sorter",
")",
"if",
"isinstance",
"(",
"arr",
","... | 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:
... | [
"Find",
"indices",
"where",
"elements",
"should",
"be",
"inserted",
"to",
"maintain",
"order",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L1744-L1820 | train |
pandas-dev/pandas | pandas/core/algorithms.py | diff | 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... | python | 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",
")",
":",
"n",
"=",
"int",
"(",
"n",
")",
"na",
"=",
"np",
".",
"nan",
"dtype",
"=",
"arr",
".",
"dtype",
"is_timedelta",
"=",
"False",
"if",
"needs_i8_conversion",
"(",
"arr",
")",
":... | 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 | [
"difference",
"of",
"n",
"between",
"self",
"analogous",
"to",
"s",
"-",
"s",
".",
"shift",
"(",
"n",
")"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L1837-L1916 | train |
pandas-dev/pandas | pandas/core/sparse/scipy_sparse.py | _to_ijv | 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... | python | 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",
")",
":",
"# index and column levels must be a partition of the index",
"_check_is_partition",
"(",
"[",
"... | For arbitrary (MultiIndexed) SparseSeries return
(v, i, j, ilabels, jlabels) where (v, (i, j)) is suitable for
passing to scipy.sparse.coo constructor. | [
"For",
"arbitrary",
"(",
"MultiIndexed",
")",
"SparseSeries",
"return",
"(",
"v",
"i",
"j",
"ilabels",
"jlabels",
")",
"where",
"(",
"v",
"(",
"i",
"j",
"))",
"is",
"suitable",
"for",
"passing",
"to",
"scipy",
".",
"sparse",
".",
"coo",
"constructor",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/scipy_sparse.py#L24-L90 | train |
pandas-dev/pandas | pandas/core/sparse/scipy_sparse.py | _sparse_series_to_coo | 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... | python | 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",
")",
":",
"import",
"scipy",
".",
"sparse",
"if",
"ss",
".",
"index",
".",
"nlevel... | 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. | [
"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",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/scipy_sparse.py#L93-L118 | train |
pandas-dev/pandas | pandas/core/sparse/scipy_sparse.py | _coo_to_sparse_series | 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 ... | python | 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",
")",
":",
"s",
"=",
"Series",
"(",
"A",
".",
"data",
",",
"MultiIndex",
".",
"from_arrays",
"(",
"(",
"A",
".",
"row",
",",
"A",
".",
"col",
")",
")",
")",
"s",
"=",
"s",... | Convert a scipy.sparse.coo_matrix to a SparseSeries.
Use the defaults given in the SparseSeries constructor. | [
"Convert",
"a",
"scipy",
".",
"sparse",
".",
"coo_matrix",
"to",
"a",
"SparseSeries",
".",
"Use",
"the",
"defaults",
"given",
"in",
"the",
"SparseSeries",
"constructor",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/scipy_sparse.py#L121-L135 | train |
pandas-dev/pandas | pandas/core/arrays/datetimes.py | _to_M8 | 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... | python | 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",
")",
":",
"if",
"not",
"isinstance",
"(",
"key",
",",
"Timestamp",
")",
":",
"# this also converts strings",
"key",
"=",
"Timestamp",
"(",
"key",
")",
"if",
"key",
".",
"tzinfo",
"is",
"not",
"None",... | Timestamp-like => dt64 | [
"Timestamp",
"-",
"like",
"=",
">",
"dt64"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L72-L85 | train |
pandas-dev/pandas | pandas/core/arrays/datetimes.py | _dt_array_cmp | 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... | python | 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",
")",
":",
"opname",
"=",
"'__{name}__'",
".",
"format",
"(",
"name",
"=",
"op",
".",
"__name__",
")",
"nat_result",
"=",
"opname",
"==",
"'__ne__'",
"def",
"wrapper",
"(",
"self",
",",
"other",
")",
":",
... | Wrap comparison operations to convert datetime-like to datetime64 | [
"Wrap",
"comparison",
"operations",
"to",
"convert",
"datetime",
"-",
"like",
"to",
"datetime64"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L126-L207 | train |
pandas-dev/pandas | pandas/core/arrays/datetimes.py | sequence_to_dt64ns | 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... | python | 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
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... | [
"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... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1669-L1800 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.