id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
20,300 | pandas-dev/pandas | pandas/core/series.py | Series.map | def map(self, arg, na_action=None):
"""
Map values of Series according to input correspondence.
Used for substituting each value in a Series with another value,
that may be derived from a function, a ``dict`` or
a :class:`Series`.
Parameters
----------
a... | python | def map(self, arg, na_action=None):
"""
Map values of Series according to input correspondence.
Used for substituting each value in a Series with another value,
that may be derived from a function, a ``dict`` or
a :class:`Series`.
Parameters
----------
a... | [
"def",
"map",
"(",
"self",
",",
"arg",
",",
"na_action",
"=",
"None",
")",
":",
"new_values",
"=",
"super",
"(",
")",
".",
"_map_values",
"(",
"arg",
",",
"na_action",
"=",
"na_action",
")",
"return",
"self",
".",
"_constructor",
"(",
"new_values",
","... | Map values of Series according to input correspondence.
Used for substituting each value in a Series with another value,
that may be derived from a function, a ``dict`` or
a :class:`Series`.
Parameters
----------
arg : function, dict, or Series
Mapping corre... | [
"Map",
"values",
"of",
"Series",
"according",
"to",
"input",
"correspondence",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/series.py#L3394-L3472 |
20,301 | pandas-dev/pandas | pandas/core/series.py | Series.apply | def apply(self, func, convert_dtype=True, args=(), **kwds):
"""
Invoke function on values of Series.
Can be ufunc (a NumPy function that applies to the entire Series)
or a Python function that only works on single values.
Parameters
----------
func : function
... | python | def apply(self, func, convert_dtype=True, args=(), **kwds):
"""
Invoke function on values of Series.
Can be ufunc (a NumPy function that applies to the entire Series)
or a Python function that only works on single values.
Parameters
----------
func : function
... | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"convert_dtype",
"=",
"True",
",",
"args",
"=",
"(",
")",
",",
"*",
"*",
"kwds",
")",
":",
"if",
"len",
"(",
"self",
")",
"==",
"0",
":",
"return",
"self",
".",
"_constructor",
"(",
"dtype",
"=",
"... | Invoke function on values of Series.
Can be ufunc (a NumPy function that applies to the entire Series)
or a Python function that only works on single values.
Parameters
----------
func : function
Python function or NumPy ufunc to apply.
convert_dtype : bool,... | [
"Invoke",
"function",
"on",
"values",
"of",
"Series",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/series.py#L3554-L3686 |
20,302 | pandas-dev/pandas | pandas/core/series.py | Series._reduce | def _reduce(self, op, name, axis=0, skipna=True, numeric_only=None,
filter_type=None, **kwds):
"""
Perform a reduction operation.
If we have an ndarray as a value, then simply perform the operation,
otherwise delegate to the object.
"""
delegate = self._v... | python | def _reduce(self, op, name, axis=0, skipna=True, numeric_only=None,
filter_type=None, **kwds):
"""
Perform a reduction operation.
If we have an ndarray as a value, then simply perform the operation,
otherwise delegate to the object.
"""
delegate = self._v... | [
"def",
"_reduce",
"(",
"self",
",",
"op",
",",
"name",
",",
"axis",
"=",
"0",
",",
"skipna",
"=",
"True",
",",
"numeric_only",
"=",
"None",
",",
"filter_type",
"=",
"None",
",",
"*",
"*",
"kwds",
")",
":",
"delegate",
"=",
"self",
".",
"_values",
... | Perform a reduction operation.
If we have an ndarray as a value, then simply perform the operation,
otherwise delegate to the object. | [
"Perform",
"a",
"reduction",
"operation",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/series.py#L3688-L3725 |
20,303 | pandas-dev/pandas | pandas/core/series.py | Series.rename | def rename(self, index=None, **kwargs):
"""
Alter Series index labels or name.
Function / dict values must be unique (1-to-1). Labels not contained in
a dict / Series will be left as-is. Extra labels listed don't throw an
error.
Alternatively, change ``Series.name`` wit... | python | def rename(self, index=None, **kwargs):
"""
Alter Series index labels or name.
Function / dict values must be unique (1-to-1). Labels not contained in
a dict / Series will be left as-is. Extra labels listed don't throw an
error.
Alternatively, change ``Series.name`` wit... | [
"def",
"rename",
"(",
"self",
",",
"index",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'inplace'",
"]",
"=",
"validate_bool_kwarg",
"(",
"kwargs",
".",
"get",
"(",
"'inplace'",
",",
"False",
")",
",",
"'inplace'",
")",
"non_mapping... | Alter Series index labels or name.
Function / dict values must be unique (1-to-1). Labels not contained in
a dict / Series will be left as-is. Extra labels listed don't throw an
error.
Alternatively, change ``Series.name`` with a scalar value.
See the :ref:`user guide <basics.... | [
"Alter",
"Series",
"index",
"labels",
"or",
"name",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/series.py#L3753-L3821 |
20,304 | pandas-dev/pandas | pandas/core/series.py | Series.reindex_axis | def reindex_axis(self, labels, axis=0, **kwargs):
"""
Conform Series to new index with optional filling logic.
.. deprecated:: 0.21.0
Use ``Series.reindex`` instead.
"""
# for compatibility with higher dims
if axis != 0:
raise ValueError("cannot r... | python | def reindex_axis(self, labels, axis=0, **kwargs):
"""
Conform Series to new index with optional filling logic.
.. deprecated:: 0.21.0
Use ``Series.reindex`` instead.
"""
# for compatibility with higher dims
if axis != 0:
raise ValueError("cannot r... | [
"def",
"reindex_axis",
"(",
"self",
",",
"labels",
",",
"axis",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"# for compatibility with higher dims",
"if",
"axis",
"!=",
"0",
":",
"raise",
"ValueError",
"(",
"\"cannot reindex series on non-zero axis!\"",
")",
"ms... | Conform Series to new index with optional filling logic.
.. deprecated:: 0.21.0
Use ``Series.reindex`` instead. | [
"Conform",
"Series",
"to",
"new",
"index",
"with",
"optional",
"filling",
"logic",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/series.py#L3940-L3954 |
20,305 | pandas-dev/pandas | pandas/core/series.py | Series.memory_usage | def memory_usage(self, index=True, deep=False):
"""
Return the memory usage of the Series.
The memory usage can optionally include the contribution of
the index and of elements of `object` dtype.
Parameters
----------
index : bool, default True
Speci... | python | def memory_usage(self, index=True, deep=False):
"""
Return the memory usage of the Series.
The memory usage can optionally include the contribution of
the index and of elements of `object` dtype.
Parameters
----------
index : bool, default True
Speci... | [
"def",
"memory_usage",
"(",
"self",
",",
"index",
"=",
"True",
",",
"deep",
"=",
"False",
")",
":",
"v",
"=",
"super",
"(",
")",
".",
"memory_usage",
"(",
"deep",
"=",
"deep",
")",
"if",
"index",
":",
"v",
"+=",
"self",
".",
"index",
".",
"memory... | Return the memory usage of the Series.
The memory usage can optionally include the contribution of
the index and of elements of `object` dtype.
Parameters
----------
index : bool, default True
Specifies whether to include the memory usage of the Series index.
... | [
"Return",
"the",
"memory",
"usage",
"of",
"the",
"Series",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/series.py#L3956-L4008 |
20,306 | pandas-dev/pandas | pandas/core/series.py | Series.isin | def isin(self, values):
"""
Check whether `values` are contained in Series.
Return a boolean Series showing whether each element in the Series
matches an element in the passed sequence of `values` exactly.
Parameters
----------
values : set or list-like
... | python | def isin(self, values):
"""
Check whether `values` are contained in Series.
Return a boolean Series showing whether each element in the Series
matches an element in the passed sequence of `values` exactly.
Parameters
----------
values : set or list-like
... | [
"def",
"isin",
"(",
"self",
",",
"values",
")",
":",
"result",
"=",
"algorithms",
".",
"isin",
"(",
"self",
",",
"values",
")",
"return",
"self",
".",
"_constructor",
"(",
"result",
",",
"index",
"=",
"self",
".",
"index",
")",
".",
"__finalize__",
"... | Check whether `values` are contained in Series.
Return a boolean Series showing whether each element in the Series
matches an element in the passed sequence of `values` exactly.
Parameters
----------
values : set or list-like
The sequence of values to test. Passing ... | [
"Check",
"whether",
"values",
"are",
"contained",
"in",
"Series",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/series.py#L4035-L4093 |
20,307 | pandas-dev/pandas | pandas/core/series.py | Series.between | def between(self, left, right, inclusive=True):
"""
Return boolean Series equivalent to left <= series <= right.
This function returns a boolean vector containing `True` wherever the
corresponding Series element is between the boundary values `left` and
`right`. NA values are tr... | python | def between(self, left, right, inclusive=True):
"""
Return boolean Series equivalent to left <= series <= right.
This function returns a boolean vector containing `True` wherever the
corresponding Series element is between the boundary values `left` and
`right`. NA values are tr... | [
"def",
"between",
"(",
"self",
",",
"left",
",",
"right",
",",
"inclusive",
"=",
"True",
")",
":",
"if",
"inclusive",
":",
"lmask",
"=",
"self",
">=",
"left",
"rmask",
"=",
"self",
"<=",
"right",
"else",
":",
"lmask",
"=",
"self",
">",
"left",
"rma... | Return boolean Series equivalent to left <= series <= right.
This function returns a boolean vector containing `True` wherever the
corresponding Series element is between the boundary values `left` and
`right`. NA values are treated as `False`.
Parameters
----------
lef... | [
"Return",
"boolean",
"Series",
"equivalent",
"to",
"left",
"<",
"=",
"series",
"<",
"=",
"right",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/series.py#L4095-L4168 |
20,308 | pandas-dev/pandas | pandas/core/series.py | Series.dropna | def dropna(self, axis=0, inplace=False, **kwargs):
"""
Return a new Series with missing values removed.
See the :ref:`User Guide <missing_data>` for more on which values are
considered missing, and how to work with missing data.
Parameters
----------
axis : {0 o... | python | def dropna(self, axis=0, inplace=False, **kwargs):
"""
Return a new Series with missing values removed.
See the :ref:`User Guide <missing_data>` for more on which values are
considered missing, and how to work with missing data.
Parameters
----------
axis : {0 o... | [
"def",
"dropna",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"inplace",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"inplace",
"=",
"validate_bool_kwarg",
"(",
"inplace",
",",
"'inplace'",
")",
"kwargs",
".",
"pop",
"(",
"'how'",
",",
"None",
")",
... | Return a new Series with missing values removed.
See the :ref:`User Guide <missing_data>` for more on which values are
considered missing, and how to work with missing data.
Parameters
----------
axis : {0 or 'index'}, default 0
There is only one axis to drop values... | [
"Return",
"a",
"new",
"Series",
"with",
"missing",
"values",
"removed",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/series.py#L4311-L4401 |
20,309 | pandas-dev/pandas | pandas/core/series.py | Series.valid | def valid(self, inplace=False, **kwargs):
"""
Return Series without null values.
.. deprecated:: 0.23.0
Use :meth:`Series.dropna` instead.
"""
warnings.warn("Method .valid will be removed in a future version. "
"Use .dropna instead.", FutureWarn... | python | def valid(self, inplace=False, **kwargs):
"""
Return Series without null values.
.. deprecated:: 0.23.0
Use :meth:`Series.dropna` instead.
"""
warnings.warn("Method .valid will be removed in a future version. "
"Use .dropna instead.", FutureWarn... | [
"def",
"valid",
"(",
"self",
",",
"inplace",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"warnings",
".",
"warn",
"(",
"\"Method .valid will be removed in a future version. \"",
"\"Use .dropna instead.\"",
",",
"FutureWarning",
",",
"stacklevel",
"=",
"2",
")... | Return Series without null values.
.. deprecated:: 0.23.0
Use :meth:`Series.dropna` instead. | [
"Return",
"Series",
"without",
"null",
"values",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/series.py#L4403-L4412 |
20,310 | pandas-dev/pandas | pandas/core/tools/numeric.py | to_numeric | def to_numeric(arg, errors='raise', downcast=None):
"""
Convert argument to a numeric type.
The default return dtype is `float64` or `int64`
depending on the data supplied. Use the `downcast` parameter
to obtain other dtypes.
Please note that precision loss may occur if really large numbers
... | python | def to_numeric(arg, errors='raise', downcast=None):
"""
Convert argument to a numeric type.
The default return dtype is `float64` or `int64`
depending on the data supplied. Use the `downcast` parameter
to obtain other dtypes.
Please note that precision loss may occur if really large numbers
... | [
"def",
"to_numeric",
"(",
"arg",
",",
"errors",
"=",
"'raise'",
",",
"downcast",
"=",
"None",
")",
":",
"if",
"downcast",
"not",
"in",
"(",
"None",
",",
"'integer'",
",",
"'signed'",
",",
"'unsigned'",
",",
"'float'",
")",
":",
"raise",
"ValueError",
"... | Convert argument to a numeric type.
The default return dtype is `float64` or `int64`
depending on the data supplied. Use the `downcast` parameter
to obtain other dtypes.
Please note that precision loss may occur if really large numbers
are passed in. Due to the internal limitations of `ndarray`, i... | [
"Convert",
"argument",
"to",
"a",
"numeric",
"type",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/tools/numeric.py#L14-L187 |
20,311 | pandas-dev/pandas | pandas/core/arrays/sparse.py | _get_fill | def _get_fill(arr: ABCSparseArray) -> np.ndarray:
"""
Create a 0-dim ndarray containing the fill value
Parameters
----------
arr : SparseArray
Returns
-------
fill_value : ndarray
0-dim ndarray with just the fill value.
Notes
-----
coerce fill_value to arr dtype if... | python | def _get_fill(arr: ABCSparseArray) -> np.ndarray:
"""
Create a 0-dim ndarray containing the fill value
Parameters
----------
arr : SparseArray
Returns
-------
fill_value : ndarray
0-dim ndarray with just the fill value.
Notes
-----
coerce fill_value to arr dtype if... | [
"def",
"_get_fill",
"(",
"arr",
":",
"ABCSparseArray",
")",
"->",
"np",
".",
"ndarray",
":",
"try",
":",
"return",
"np",
".",
"asarray",
"(",
"arr",
".",
"fill_value",
",",
"dtype",
"=",
"arr",
".",
"dtype",
".",
"subtype",
")",
"except",
"ValueError",... | Create a 0-dim ndarray containing the fill value
Parameters
----------
arr : SparseArray
Returns
-------
fill_value : ndarray
0-dim ndarray with just the fill value.
Notes
-----
coerce fill_value to arr dtype if possible
int64 SparseArray can have NaN as fill_value if ... | [
"Create",
"a",
"0",
"-",
"dim",
"ndarray",
"containing",
"the",
"fill",
"value"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L386-L407 |
20,312 | pandas-dev/pandas | pandas/core/arrays/sparse.py | _sparse_array_op | def _sparse_array_op(
left: ABCSparseArray,
right: ABCSparseArray,
op: Callable,
name: str
) -> Any:
"""
Perform a binary operation between two arrays.
Parameters
----------
left : Union[SparseArray, ndarray]
right : Union[SparseArray, ndarray]
op : Callable
... | python | def _sparse_array_op(
left: ABCSparseArray,
right: ABCSparseArray,
op: Callable,
name: str
) -> Any:
"""
Perform a binary operation between two arrays.
Parameters
----------
left : Union[SparseArray, ndarray]
right : Union[SparseArray, ndarray]
op : Callable
... | [
"def",
"_sparse_array_op",
"(",
"left",
":",
"ABCSparseArray",
",",
"right",
":",
"ABCSparseArray",
",",
"op",
":",
"Callable",
",",
"name",
":",
"str",
")",
"->",
"Any",
":",
"if",
"name",
".",
"startswith",
"(",
"'__'",
")",
":",
"# For lookups in _libs.... | Perform a binary operation between two arrays.
Parameters
----------
left : Union[SparseArray, ndarray]
right : Union[SparseArray, ndarray]
op : Callable
The binary operation to perform
name str
Name of the callable.
Returns
-------
SparseArray | [
"Perform",
"a",
"binary",
"operation",
"between",
"two",
"arrays",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L410-L495 |
20,313 | pandas-dev/pandas | pandas/core/arrays/sparse.py | _wrap_result | def _wrap_result(name, data, sparse_index, fill_value, dtype=None):
"""
wrap op result to have correct dtype
"""
if name.startswith('__'):
# e.g. __eq__ --> eq
name = name[2:-2]
if name in ('eq', 'ne', 'lt', 'gt', 'le', 'ge'):
dtype = np.bool
fill_value = lib.item_from_... | python | def _wrap_result(name, data, sparse_index, fill_value, dtype=None):
"""
wrap op result to have correct dtype
"""
if name.startswith('__'):
# e.g. __eq__ --> eq
name = name[2:-2]
if name in ('eq', 'ne', 'lt', 'gt', 'le', 'ge'):
dtype = np.bool
fill_value = lib.item_from_... | [
"def",
"_wrap_result",
"(",
"name",
",",
"data",
",",
"sparse_index",
",",
"fill_value",
",",
"dtype",
"=",
"None",
")",
":",
"if",
"name",
".",
"startswith",
"(",
"'__'",
")",
":",
"# e.g. __eq__ --> eq",
"name",
"=",
"name",
"[",
"2",
":",
"-",
"2",
... | wrap op result to have correct dtype | [
"wrap",
"op",
"result",
"to",
"have",
"correct",
"dtype"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L498-L517 |
20,314 | pandas-dev/pandas | pandas/core/arrays/sparse.py | _maybe_to_sparse | def _maybe_to_sparse(array):
"""
array must be SparseSeries or SparseArray
"""
if isinstance(array, ABCSparseSeries):
array = array.values.copy()
return array | python | def _maybe_to_sparse(array):
"""
array must be SparseSeries or SparseArray
"""
if isinstance(array, ABCSparseSeries):
array = array.values.copy()
return array | [
"def",
"_maybe_to_sparse",
"(",
"array",
")",
":",
"if",
"isinstance",
"(",
"array",
",",
"ABCSparseSeries",
")",
":",
"array",
"=",
"array",
".",
"values",
".",
"copy",
"(",
")",
"return",
"array"
] | array must be SparseSeries or SparseArray | [
"array",
"must",
"be",
"SparseSeries",
"or",
"SparseArray"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L1803-L1809 |
20,315 | pandas-dev/pandas | pandas/core/arrays/sparse.py | _sanitize_values | def _sanitize_values(arr):
"""
return an ndarray for our input,
in a platform independent manner
"""
if hasattr(arr, 'values'):
arr = arr.values
else:
# scalar
if is_scalar(arr):
arr = [arr]
# ndarray
if isinstance(arr, np.ndarray):
... | python | def _sanitize_values(arr):
"""
return an ndarray for our input,
in a platform independent manner
"""
if hasattr(arr, 'values'):
arr = arr.values
else:
# scalar
if is_scalar(arr):
arr = [arr]
# ndarray
if isinstance(arr, np.ndarray):
... | [
"def",
"_sanitize_values",
"(",
"arr",
")",
":",
"if",
"hasattr",
"(",
"arr",
",",
"'values'",
")",
":",
"arr",
"=",
"arr",
".",
"values",
"else",
":",
"# scalar",
"if",
"is_scalar",
"(",
"arr",
")",
":",
"arr",
"=",
"[",
"arr",
"]",
"# ndarray",
"... | return an ndarray for our input,
in a platform independent manner | [
"return",
"an",
"ndarray",
"for",
"our",
"input",
"in",
"a",
"platform",
"independent",
"manner"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L1812-L1836 |
20,316 | pandas-dev/pandas | pandas/core/arrays/sparse.py | make_sparse | def make_sparse(arr, kind='block', fill_value=None, dtype=None, copy=False):
"""
Convert ndarray to sparse format
Parameters
----------
arr : ndarray
kind : {'block', 'integer'}
fill_value : NaN or another value
dtype : np.dtype, optional
copy : bool, default False
Returns
... | python | def make_sparse(arr, kind='block', fill_value=None, dtype=None, copy=False):
"""
Convert ndarray to sparse format
Parameters
----------
arr : ndarray
kind : {'block', 'integer'}
fill_value : NaN or another value
dtype : np.dtype, optional
copy : bool, default False
Returns
... | [
"def",
"make_sparse",
"(",
"arr",
",",
"kind",
"=",
"'block'",
",",
"fill_value",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"copy",
"=",
"False",
")",
":",
"arr",
"=",
"_sanitize_values",
"(",
"arr",
")",
"if",
"arr",
".",
"ndim",
">",
"1",
":",... | Convert ndarray to sparse format
Parameters
----------
arr : ndarray
kind : {'block', 'integer'}
fill_value : NaN or another value
dtype : np.dtype, optional
copy : bool, default False
Returns
-------
(sparse_values, index, fill_value) : (ndarray, SparseIndex, Scalar) | [
"Convert",
"ndarray",
"to",
"sparse",
"format"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L1839-L1891 |
20,317 | pandas-dev/pandas | pandas/core/arrays/sparse.py | SparseArray.density | def density(self):
"""
The percent of non- ``fill_value`` points, as decimal.
Examples
--------
>>> s = SparseArray([0, 0, 1, 1, 1], fill_value=0)
>>> s.density
0.6
"""
r = float(self.sp_index.npoints) / float(self.sp_index.length)
return ... | python | def density(self):
"""
The percent of non- ``fill_value`` points, as decimal.
Examples
--------
>>> s = SparseArray([0, 0, 1, 1, 1], fill_value=0)
>>> s.density
0.6
"""
r = float(self.sp_index.npoints) / float(self.sp_index.length)
return ... | [
"def",
"density",
"(",
"self",
")",
":",
"r",
"=",
"float",
"(",
"self",
".",
"sp_index",
".",
"npoints",
")",
"/",
"float",
"(",
"self",
".",
"sp_index",
".",
"length",
")",
"return",
"r"
] | The percent of non- ``fill_value`` points, as decimal.
Examples
--------
>>> s = SparseArray([0, 0, 1, 1, 1], fill_value=0)
>>> s.density
0.6 | [
"The",
"percent",
"of",
"non",
"-",
"fill_value",
"points",
"as",
"decimal",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L814-L825 |
20,318 | pandas-dev/pandas | pandas/core/arrays/sparse.py | SparseArray.fillna | def fillna(self, value=None, method=None, limit=None):
"""
Fill missing values with `value`.
Parameters
----------
value : scalar, optional
method : str, optional
.. warning::
Using 'method' will result in high memory use,
as a... | python | def fillna(self, value=None, method=None, limit=None):
"""
Fill missing values with `value`.
Parameters
----------
value : scalar, optional
method : str, optional
.. warning::
Using 'method' will result in high memory use,
as a... | [
"def",
"fillna",
"(",
"self",
",",
"value",
"=",
"None",
",",
"method",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"if",
"(",
"(",
"method",
"is",
"None",
"and",
"value",
"is",
"None",
")",
"or",
"(",
"method",
"is",
"not",
"None",
"and",
... | Fill missing values with `value`.
Parameters
----------
value : scalar, optional
method : str, optional
.. warning::
Using 'method' will result in high memory use,
as all `fill_value` methods will be converted to
an in-memory nd... | [
"Fill",
"missing",
"values",
"with",
"value",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L855-L908 |
20,319 | pandas-dev/pandas | pandas/core/arrays/sparse.py | SparseArray._first_fill_value_loc | def _first_fill_value_loc(self):
"""
Get the location of the first missing value.
Returns
-------
int
"""
if len(self) == 0 or self.sp_index.npoints == len(self):
return -1
indices = self.sp_index.to_int_index().indices
if not len(ind... | python | def _first_fill_value_loc(self):
"""
Get the location of the first missing value.
Returns
-------
int
"""
if len(self) == 0 or self.sp_index.npoints == len(self):
return -1
indices = self.sp_index.to_int_index().indices
if not len(ind... | [
"def",
"_first_fill_value_loc",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
")",
"==",
"0",
"or",
"self",
".",
"sp_index",
".",
"npoints",
"==",
"len",
"(",
"self",
")",
":",
"return",
"-",
"1",
"indices",
"=",
"self",
".",
"sp_index",
".",
"t... | Get the location of the first missing value.
Returns
-------
int | [
"Get",
"the",
"location",
"of",
"the",
"first",
"missing",
"value",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L939-L955 |
20,320 | pandas-dev/pandas | pandas/core/arrays/sparse.py | SparseArray.value_counts | def value_counts(self, dropna=True):
"""
Returns a Series containing counts of unique values.
Parameters
----------
dropna : boolean, default True
Don't include counts of NaN, even if NaN is in sp_values.
Returns
-------
counts : Series
... | python | def value_counts(self, dropna=True):
"""
Returns a Series containing counts of unique values.
Parameters
----------
dropna : boolean, default True
Don't include counts of NaN, even if NaN is in sp_values.
Returns
-------
counts : Series
... | [
"def",
"value_counts",
"(",
"self",
",",
"dropna",
"=",
"True",
")",
":",
"from",
"pandas",
"import",
"Index",
",",
"Series",
"keys",
",",
"counts",
"=",
"algos",
".",
"_value_counts_arraylike",
"(",
"self",
".",
"sp_values",
",",
"dropna",
"=",
"dropna",
... | Returns a Series containing counts of unique values.
Parameters
----------
dropna : boolean, default True
Don't include counts of NaN, even if NaN is in sp_values.
Returns
-------
counts : Series | [
"Returns",
"a",
"Series",
"containing",
"counts",
"of",
"unique",
"values",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/sparse.py#L979-L1015 |
20,321 | 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 |
20,322 | 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 |
20,323 | 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 |
20,324 | 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 |
20,325 | 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 |
20,326 | 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 |
20,327 | 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 |
20,328 | 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 |
20,329 | 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 |
20,330 | 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 |
20,331 | 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 |
20,332 | 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 |
20,333 | 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 |
20,334 | 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 |
20,335 | 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 |
20,336 | 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 |
20,337 | 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 |
20,338 | 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 |
20,339 | 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 |
20,340 | 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 |
20,341 | 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 |
20,342 | 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 |
20,343 | 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 |
20,344 | 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 |
20,345 | 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 |
20,346 | 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 |
20,347 | 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 |
20,348 | 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 |
20,349 | 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 |
20,350 | 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 |
20,351 | 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 |
20,352 | 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 |
20,353 | 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 |
20,354 | 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 |
20,355 | 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 |
20,356 | 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 |
20,357 | 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 |
20,358 | 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 |
20,359 | 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 |
20,360 | 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 |
20,361 | 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 |
20,362 | 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 |
20,363 | 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 |
20,364 | 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 |
20,365 | 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 |
20,366 | 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 |
20,367 | 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 |
20,368 | 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 |
20,369 | 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 |
20,370 | 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 |
20,371 | 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 |
20,372 | 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 |
20,373 | 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 |
20,374 | 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 |
20,375 | 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 |
20,376 | 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 |
20,377 | 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 |
20,378 | 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 |
20,379 | 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 |
20,380 | 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 |
20,381 | 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 |
20,382 | 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 |
20,383 | 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 |
20,384 | 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 |
20,385 | 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 |
20,386 | 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 |
20,387 | 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 |
20,388 | 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 |
20,389 | 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 |
20,390 | 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 |
20,391 | 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 |
20,392 | 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 |
20,393 | 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 |
20,394 | pandas-dev/pandas | pandas/core/arrays/datetimes.py | objects_to_datetime64ns | def objects_to_datetime64ns(data, dayfirst, yearfirst,
utc=False, errors="raise",
require_iso8601=False, allow_object=False):
"""
Convert data to array of timestamps.
Parameters
----------
data : np.ndarray[object]
dayfirst : bool
year... | python | def objects_to_datetime64ns(data, dayfirst, yearfirst,
utc=False, errors="raise",
require_iso8601=False, allow_object=False):
"""
Convert data to array of timestamps.
Parameters
----------
data : np.ndarray[object]
dayfirst : bool
year... | [
"def",
"objects_to_datetime64ns",
"(",
"data",
",",
"dayfirst",
",",
"yearfirst",
",",
"utc",
"=",
"False",
",",
"errors",
"=",
"\"raise\"",
",",
"require_iso8601",
"=",
"False",
",",
"allow_object",
"=",
"False",
")",
":",
"assert",
"errors",
"in",
"[",
"... | Convert data to array of timestamps.
Parameters
----------
data : np.ndarray[object]
dayfirst : bool
yearfirst : bool
utc : bool, default False
Whether to convert timezone-aware timestamps to UTC
errors : {'raise', 'ignore', 'coerce'}
allow_object : bool
Whether to retur... | [
"Convert",
"data",
"to",
"array",
"of",
"timestamps",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1803-L1877 |
20,395 | pandas-dev/pandas | pandas/core/arrays/datetimes.py | maybe_convert_dtype | def maybe_convert_dtype(data, copy):
"""
Convert data based on dtype conventions, issuing deprecation warnings
or errors where appropriate.
Parameters
----------
data : np.ndarray or pd.Index
copy : bool
Returns
-------
data : np.ndarray or pd.Index
copy : bool
Raises
... | python | def maybe_convert_dtype(data, copy):
"""
Convert data based on dtype conventions, issuing deprecation warnings
or errors where appropriate.
Parameters
----------
data : np.ndarray or pd.Index
copy : bool
Returns
-------
data : np.ndarray or pd.Index
copy : bool
Raises
... | [
"def",
"maybe_convert_dtype",
"(",
"data",
",",
"copy",
")",
":",
"if",
"is_float_dtype",
"(",
"data",
")",
":",
"# Note: we must cast to datetime64[ns] here in order to treat these",
"# as wall-times instead of UTC timestamps.",
"data",
"=",
"data",
".",
"astype",
"(",
... | Convert data based on dtype conventions, issuing deprecation warnings
or errors where appropriate.
Parameters
----------
data : np.ndarray or pd.Index
copy : bool
Returns
-------
data : np.ndarray or pd.Index
copy : bool
Raises
------
TypeError : PeriodDType data is pa... | [
"Convert",
"data",
"based",
"on",
"dtype",
"conventions",
"issuing",
"deprecation",
"warnings",
"or",
"errors",
"where",
"appropriate",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1880-L1932 |
20,396 | pandas-dev/pandas | pandas/core/arrays/datetimes.py | maybe_infer_tz | def maybe_infer_tz(tz, inferred_tz):
"""
If a timezone is inferred from data, check that it is compatible with
the user-provided timezone, if any.
Parameters
----------
tz : tzinfo or None
inferred_tz : tzinfo or None
Returns
-------
tz : tzinfo or None
Raises
------
... | python | def maybe_infer_tz(tz, inferred_tz):
"""
If a timezone is inferred from data, check that it is compatible with
the user-provided timezone, if any.
Parameters
----------
tz : tzinfo or None
inferred_tz : tzinfo or None
Returns
-------
tz : tzinfo or None
Raises
------
... | [
"def",
"maybe_infer_tz",
"(",
"tz",
",",
"inferred_tz",
")",
":",
"if",
"tz",
"is",
"None",
":",
"tz",
"=",
"inferred_tz",
"elif",
"inferred_tz",
"is",
"None",
":",
"pass",
"elif",
"not",
"timezones",
".",
"tz_compare",
"(",
"tz",
",",
"inferred_tz",
")"... | If a timezone is inferred from data, check that it is compatible with
the user-provided timezone, if any.
Parameters
----------
tz : tzinfo or None
inferred_tz : tzinfo or None
Returns
-------
tz : tzinfo or None
Raises
------
TypeError : if both timezones are present but ... | [
"If",
"a",
"timezone",
"is",
"inferred",
"from",
"data",
"check",
"that",
"it",
"is",
"compatible",
"with",
"the",
"user",
"-",
"provided",
"timezone",
"if",
"any",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1938-L1964 |
20,397 | pandas-dev/pandas | pandas/core/arrays/datetimes.py | validate_tz_from_dtype | def validate_tz_from_dtype(dtype, tz):
"""
If the given dtype is a DatetimeTZDtype, extract the implied
tzinfo object from it and check that it does not conflict with the given
tz.
Parameters
----------
dtype : dtype, str
tz : None, tzinfo
Returns
-------
tz : consensus tzi... | python | def validate_tz_from_dtype(dtype, tz):
"""
If the given dtype is a DatetimeTZDtype, extract the implied
tzinfo object from it and check that it does not conflict with the given
tz.
Parameters
----------
dtype : dtype, str
tz : None, tzinfo
Returns
-------
tz : consensus tzi... | [
"def",
"validate_tz_from_dtype",
"(",
"dtype",
",",
"tz",
")",
":",
"if",
"dtype",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"dtype",
",",
"str",
")",
":",
"try",
":",
"dtype",
"=",
"DatetimeTZDtype",
".",
"construct_from_string",
"(",
"dtype",
... | If the given dtype is a DatetimeTZDtype, extract the implied
tzinfo object from it and check that it does not conflict with the given
tz.
Parameters
----------
dtype : dtype, str
tz : None, tzinfo
Returns
-------
tz : consensus tzinfo
Raises
------
ValueError : on tzin... | [
"If",
"the",
"given",
"dtype",
"is",
"a",
"DatetimeTZDtype",
"extract",
"the",
"implied",
"tzinfo",
"object",
"from",
"it",
"and",
"check",
"that",
"it",
"does",
"not",
"conflict",
"with",
"the",
"given",
"tz",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L2008-L2051 |
20,398 | pandas-dev/pandas | pandas/core/arrays/datetimes.py | _infer_tz_from_endpoints | def _infer_tz_from_endpoints(start, end, tz):
"""
If a timezone is not explicitly given via `tz`, see if one can
be inferred from the `start` and `end` endpoints. If more than one
of these inputs provides a timezone, require that they all agree.
Parameters
----------
start : Timestamp
... | python | def _infer_tz_from_endpoints(start, end, tz):
"""
If a timezone is not explicitly given via `tz`, see if one can
be inferred from the `start` and `end` endpoints. If more than one
of these inputs provides a timezone, require that they all agree.
Parameters
----------
start : Timestamp
... | [
"def",
"_infer_tz_from_endpoints",
"(",
"start",
",",
"end",
",",
"tz",
")",
":",
"try",
":",
"inferred_tz",
"=",
"timezones",
".",
"infer_tzinfo",
"(",
"start",
",",
"end",
")",
"except",
"Exception",
":",
"raise",
"TypeError",
"(",
"'Start and end cannot bot... | If a timezone is not explicitly given via `tz`, see if one can
be inferred from the `start` and `end` endpoints. If more than one
of these inputs provides a timezone, require that they all agree.
Parameters
----------
start : Timestamp
end : Timestamp
tz : tzinfo or None
Returns
-... | [
"If",
"a",
"timezone",
"is",
"not",
"explicitly",
"given",
"via",
"tz",
"see",
"if",
"one",
"can",
"be",
"inferred",
"from",
"the",
"start",
"and",
"end",
"endpoints",
".",
"If",
"more",
"than",
"one",
"of",
"these",
"inputs",
"provides",
"a",
"timezone"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L2054-L2091 |
20,399 | pandas-dev/pandas | pandas/core/arrays/datetimes.py | _maybe_localize_point | def _maybe_localize_point(ts, is_none, is_not_none, freq, tz):
"""
Localize a start or end Timestamp to the timezone of the corresponding
start or end Timestamp
Parameters
----------
ts : start or end Timestamp to potentially localize
is_none : argument that should be None
is_not_none :... | python | def _maybe_localize_point(ts, is_none, is_not_none, freq, tz):
"""
Localize a start or end Timestamp to the timezone of the corresponding
start or end Timestamp
Parameters
----------
ts : start or end Timestamp to potentially localize
is_none : argument that should be None
is_not_none :... | [
"def",
"_maybe_localize_point",
"(",
"ts",
",",
"is_none",
",",
"is_not_none",
",",
"freq",
",",
"tz",
")",
":",
"# Make sure start and end are timezone localized if:",
"# 1) freq = a Timedelta-like frequency (Tick)",
"# 2) freq = None i.e. generating a linspaced range",
"if",
"i... | Localize a start or end Timestamp to the timezone of the corresponding
start or end Timestamp
Parameters
----------
ts : start or end Timestamp to potentially localize
is_none : argument that should be None
is_not_none : argument that should not be None
freq : Tick, DateOffset, or None
... | [
"Localize",
"a",
"start",
"or",
"end",
"Timestamp",
"to",
"the",
"timezone",
"of",
"the",
"corresponding",
"start",
"or",
"end",
"Timestamp"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L2114-L2140 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.