repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
pandas-dev/pandas | pandas/core/frame.py | DataFrame._box_col_values | def _box_col_values(self, values, items):
"""
Provide boxed values for a column.
"""
klass = self._constructor_sliced
return klass(values, index=self.index, name=items, fastpath=True) | python | def _box_col_values(self, values, items):
"""
Provide boxed values for a column.
"""
klass = self._constructor_sliced
return klass(values, index=self.index, name=items, fastpath=True) | [
"def",
"_box_col_values",
"(",
"self",
",",
"values",
",",
"items",
")",
":",
"klass",
"=",
"self",
".",
"_constructor_sliced",
"return",
"klass",
"(",
"values",
",",
"index",
"=",
"self",
".",
"index",
",",
"name",
"=",
"items",
",",
"fastpath",
"=",
... | Provide boxed values for a column. | [
"Provide",
"boxed",
"values",
"for",
"a",
"column",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L3333-L3338 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame._ensure_valid_index | def _ensure_valid_index(self, value):
"""
Ensure that if we don't have an index, that we can create one from the
passed value.
"""
# GH5632, make sure that we are a Series convertible
if not len(self.index) and is_list_like(value):
try:
value =... | python | def _ensure_valid_index(self, value):
"""
Ensure that if we don't have an index, that we can create one from the
passed value.
"""
# GH5632, make sure that we are a Series convertible
if not len(self.index) and is_list_like(value):
try:
value =... | [
"def",
"_ensure_valid_index",
"(",
"self",
",",
"value",
")",
":",
"# GH5632, make sure that we are a Series convertible",
"if",
"not",
"len",
"(",
"self",
".",
"index",
")",
"and",
"is_list_like",
"(",
"value",
")",
":",
"try",
":",
"value",
"=",
"Series",
"(... | Ensure that if we don't have an index, that we can create one from the
passed value. | [
"Ensure",
"that",
"if",
"we",
"don",
"t",
"have",
"an",
"index",
"that",
"we",
"can",
"create",
"one",
"from",
"the",
"passed",
"value",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L3400-L3415 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame._set_item | def _set_item(self, key, value):
"""
Add series to DataFrame in specified column.
If series is a numpy-array (not a Series/TimeSeries), it must be the
same length as the DataFrames index or an error will be thrown.
Series/TimeSeries will be conformed to the DataFrames index to
... | python | def _set_item(self, key, value):
"""
Add series to DataFrame in specified column.
If series is a numpy-array (not a Series/TimeSeries), it must be the
same length as the DataFrames index or an error will be thrown.
Series/TimeSeries will be conformed to the DataFrames index to
... | [
"def",
"_set_item",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"_ensure_valid_index",
"(",
"value",
")",
"value",
"=",
"self",
".",
"_sanitize_column",
"(",
"key",
",",
"value",
")",
"NDFrame",
".",
"_set_item",
"(",
"self",
",",
"ke... | Add series to DataFrame in specified column.
If series is a numpy-array (not a Series/TimeSeries), it must be the
same length as the DataFrames index or an error will be thrown.
Series/TimeSeries will be conformed to the DataFrames index to
ensure homogeneity. | [
"Add",
"series",
"to",
"DataFrame",
"in",
"specified",
"column",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L3417-L3436 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.insert | def insert(self, loc, column, value, allow_duplicates=False):
"""
Insert column into DataFrame at specified location.
Raises a ValueError if `column` is already contained in the DataFrame,
unless `allow_duplicates` is set to True.
Parameters
----------
loc : int... | python | def insert(self, loc, column, value, allow_duplicates=False):
"""
Insert column into DataFrame at specified location.
Raises a ValueError if `column` is already contained in the DataFrame,
unless `allow_duplicates` is set to True.
Parameters
----------
loc : int... | [
"def",
"insert",
"(",
"self",
",",
"loc",
",",
"column",
",",
"value",
",",
"allow_duplicates",
"=",
"False",
")",
":",
"self",
".",
"_ensure_valid_index",
"(",
"value",
")",
"value",
"=",
"self",
".",
"_sanitize_column",
"(",
"column",
",",
"value",
","... | Insert column into DataFrame at specified location.
Raises a ValueError if `column` is already contained in the DataFrame,
unless `allow_duplicates` is set to True.
Parameters
----------
loc : int
Insertion index. Must verify 0 <= loc <= len(columns)
column ... | [
"Insert",
"column",
"into",
"DataFrame",
"at",
"specified",
"location",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L3438-L3457 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.assign | def assign(self, **kwargs):
r"""
Assign new columns to a DataFrame.
Returns a new object with all original columns in addition to new ones.
Existing columns that are re-assigned will be overwritten.
Parameters
----------
**kwargs : dict of {str: callable or Seri... | python | def assign(self, **kwargs):
r"""
Assign new columns to a DataFrame.
Returns a new object with all original columns in addition to new ones.
Existing columns that are re-assigned will be overwritten.
Parameters
----------
**kwargs : dict of {str: callable or Seri... | [
"def",
"assign",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"copy",
"(",
")",
"# >= 3.6 preserve order of kwargs",
"if",
"PY36",
":",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"data",
"[",
"k"... | r"""
Assign new columns to a DataFrame.
Returns a new object with all original columns in addition to new ones.
Existing columns that are re-assigned will be overwritten.
Parameters
----------
**kwargs : dict of {str: callable or Series}
The column names are... | [
"r",
"Assign",
"new",
"columns",
"to",
"a",
"DataFrame",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L3459-L3547 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame._sanitize_column | def _sanitize_column(self, key, value, broadcast=True):
"""
Ensures new columns (which go into the BlockManager as new blocks) are
always copied and converted into an array.
Parameters
----------
key : object
value : scalar, Series, or array-like
broadcas... | python | def _sanitize_column(self, key, value, broadcast=True):
"""
Ensures new columns (which go into the BlockManager as new blocks) are
always copied and converted into an array.
Parameters
----------
key : object
value : scalar, Series, or array-like
broadcas... | [
"def",
"_sanitize_column",
"(",
"self",
",",
"key",
",",
"value",
",",
"broadcast",
"=",
"True",
")",
":",
"def",
"reindexer",
"(",
"value",
")",
":",
"# reindex if necessary",
"if",
"value",
".",
"index",
".",
"equals",
"(",
"self",
".",
"index",
")",
... | Ensures new columns (which go into the BlockManager as new blocks) are
always copied and converted into an array.
Parameters
----------
key : object
value : scalar, Series, or array-like
broadcast : bool, default True
If ``key`` matches multiple duplicate col... | [
"Ensures",
"new",
"columns",
"(",
"which",
"go",
"into",
"the",
"BlockManager",
"as",
"new",
"blocks",
")",
"are",
"always",
"copied",
"and",
"converted",
"into",
"an",
"array",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L3549-L3652 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.lookup | def lookup(self, row_labels, col_labels):
"""
Label-based "fancy indexing" function for DataFrame.
Given equal-length arrays of row and column labels, return an
array of the values corresponding to each (row, col) pair.
Parameters
----------
row_labels : sequenc... | python | def lookup(self, row_labels, col_labels):
"""
Label-based "fancy indexing" function for DataFrame.
Given equal-length arrays of row and column labels, return an
array of the values corresponding to each (row, col) pair.
Parameters
----------
row_labels : sequenc... | [
"def",
"lookup",
"(",
"self",
",",
"row_labels",
",",
"col_labels",
")",
":",
"n",
"=",
"len",
"(",
"row_labels",
")",
"if",
"n",
"!=",
"len",
"(",
"col_labels",
")",
":",
"raise",
"ValueError",
"(",
"'Row labels must have same size as column labels'",
")",
... | Label-based "fancy indexing" function for DataFrame.
Given equal-length arrays of row and column labels, return an
array of the values corresponding to each (row, col) pair.
Parameters
----------
row_labels : sequence
The row labels to use for lookup
col_lab... | [
"Label",
"-",
"based",
"fancy",
"indexing",
"function",
"for",
"DataFrame",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L3659-L3708 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame._reindex_multi | def _reindex_multi(self, axes, copy, fill_value):
"""
We are guaranteed non-Nones in the axes.
"""
new_index, row_indexer = self.index.reindex(axes['index'])
new_columns, col_indexer = self.columns.reindex(axes['columns'])
if row_indexer is not None and col_indexer is n... | python | def _reindex_multi(self, axes, copy, fill_value):
"""
We are guaranteed non-Nones in the axes.
"""
new_index, row_indexer = self.index.reindex(axes['index'])
new_columns, col_indexer = self.columns.reindex(axes['columns'])
if row_indexer is not None and col_indexer is n... | [
"def",
"_reindex_multi",
"(",
"self",
",",
"axes",
",",
"copy",
",",
"fill_value",
")",
":",
"new_index",
",",
"row_indexer",
"=",
"self",
".",
"index",
".",
"reindex",
"(",
"axes",
"[",
"'index'",
"]",
")",
"new_columns",
",",
"col_indexer",
"=",
"self"... | We are guaranteed non-Nones in the axes. | [
"We",
"are",
"guaranteed",
"non",
"-",
"Nones",
"in",
"the",
"axes",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L3747-L3765 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.drop | def drop(self, labels=None, axis=0, index=None, columns=None,
level=None, inplace=False, errors='raise'):
"""
Drop specified labels from rows or columns.
Remove rows or columns by specifying label names and corresponding
axis, or by specifying directly index or column names... | python | def drop(self, labels=None, axis=0, index=None, columns=None,
level=None, inplace=False, errors='raise'):
"""
Drop specified labels from rows or columns.
Remove rows or columns by specifying label names and corresponding
axis, or by specifying directly index or column names... | [
"def",
"drop",
"(",
"self",
",",
"labels",
"=",
"None",
",",
"axis",
"=",
"0",
",",
"index",
"=",
"None",
",",
"columns",
"=",
"None",
",",
"level",
"=",
"None",
",",
"inplace",
"=",
"False",
",",
"errors",
"=",
"'raise'",
")",
":",
"return",
"su... | Drop specified labels from rows or columns.
Remove rows or columns by specifying label names and corresponding
axis, or by specifying directly index or column names. When using a
multi-index, labels on different levels can be removed by specifying
the level.
Parameters
... | [
"Drop",
"specified",
"labels",
"from",
"rows",
"or",
"columns",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L3800-L3926 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.rename | def rename(self, *args, **kwargs):
"""
Alter axes labels.
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.
See the :ref:`user guide <basics.rename>` for more.
P... | python | def rename(self, *args, **kwargs):
"""
Alter axes labels.
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.
See the :ref:`user guide <basics.rename>` for more.
P... | [
"def",
"rename",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"axes",
"=",
"validate_axis_style_args",
"(",
"self",
",",
"args",
",",
"kwargs",
",",
"'mapper'",
",",
"'rename'",
")",
"kwargs",
".",
"update",
"(",
"axes",
")",
"# ... | Alter axes labels.
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.
See the :ref:`user guide <basics.rename>` for more.
Parameters
----------
mapper : dict-like... | [
"Alter",
"axes",
"labels",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L3932-L4035 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.set_index | def set_index(self, keys, drop=True, append=False, inplace=False,
verify_integrity=False):
"""
Set the DataFrame index using existing columns.
Set the DataFrame index (row labels) using one or more existing
columns or arrays (of the correct length). The index can repla... | python | def set_index(self, keys, drop=True, append=False, inplace=False,
verify_integrity=False):
"""
Set the DataFrame index using existing columns.
Set the DataFrame index (row labels) using one or more existing
columns or arrays (of the correct length). The index can repla... | [
"def",
"set_index",
"(",
"self",
",",
"keys",
",",
"drop",
"=",
"True",
",",
"append",
"=",
"False",
",",
"inplace",
"=",
"False",
",",
"verify_integrity",
"=",
"False",
")",
":",
"inplace",
"=",
"validate_bool_kwarg",
"(",
"inplace",
",",
"'inplace'",
"... | Set the DataFrame index using existing columns.
Set the DataFrame index (row labels) using one or more existing
columns or arrays (of the correct length). The index can replace the
existing index or expand on it.
Parameters
----------
keys : label or array-like or list ... | [
"Set",
"the",
"DataFrame",
"index",
"using",
"existing",
"columns",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L4057-L4242 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.reset_index | def reset_index(self, level=None, drop=False, inplace=False, col_level=0,
col_fill=''):
"""
Reset the index, or a level of it.
Reset the index of the DataFrame, and use the default one instead.
If the DataFrame has a MultiIndex, this method can remove one or more
... | python | def reset_index(self, level=None, drop=False, inplace=False, col_level=0,
col_fill=''):
"""
Reset the index, or a level of it.
Reset the index of the DataFrame, and use the default one instead.
If the DataFrame has a MultiIndex, this method can remove one or more
... | [
"def",
"reset_index",
"(",
"self",
",",
"level",
"=",
"None",
",",
"drop",
"=",
"False",
",",
"inplace",
"=",
"False",
",",
"col_level",
"=",
"0",
",",
"col_fill",
"=",
"''",
")",
":",
"inplace",
"=",
"validate_bool_kwarg",
"(",
"inplace",
",",
"'inpla... | Reset the index, or a level of it.
Reset the index of the DataFrame, and use the default one instead.
If the DataFrame has a MultiIndex, this method can remove one or more
levels.
Parameters
----------
level : int, str, tuple, or list, default None
Only remo... | [
"Reset",
"the",
"index",
"or",
"a",
"level",
"of",
"it",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L4244-L4476 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.dropna | def dropna(self, axis=0, how='any', thresh=None, subset=None,
inplace=False):
"""
Remove missing values.
See the :ref:`User Guide <missing_data>` for more on which values are
considered missing, and how to work with missing data.
Parameters
----------
... | python | def dropna(self, axis=0, how='any', thresh=None, subset=None,
inplace=False):
"""
Remove missing values.
See the :ref:`User Guide <missing_data>` for more on which values are
considered missing, and how to work with missing data.
Parameters
----------
... | [
"def",
"dropna",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"how",
"=",
"'any'",
",",
"thresh",
"=",
"None",
",",
"subset",
"=",
"None",
",",
"inplace",
"=",
"False",
")",
":",
"inplace",
"=",
"validate_bool_kwarg",
"(",
"inplace",
",",
"'inplace'",
")... | Remove missing values.
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', 1 or 'columns'}, default 0
Determine if rows or columns which contain miss... | [
"Remove",
"missing",
"values",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L4497-L4644 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.drop_duplicates | def drop_duplicates(self, subset=None, keep='first', inplace=False):
"""
Return DataFrame with duplicate rows removed, optionally only
considering certain columns. Indexes, including time indexes
are ignored.
Parameters
----------
subset : column label or sequenc... | python | def drop_duplicates(self, subset=None, keep='first', inplace=False):
"""
Return DataFrame with duplicate rows removed, optionally only
considering certain columns. Indexes, including time indexes
are ignored.
Parameters
----------
subset : column label or sequenc... | [
"def",
"drop_duplicates",
"(",
"self",
",",
"subset",
"=",
"None",
",",
"keep",
"=",
"'first'",
",",
"inplace",
"=",
"False",
")",
":",
"if",
"self",
".",
"empty",
":",
"return",
"self",
".",
"copy",
"(",
")",
"inplace",
"=",
"validate_bool_kwarg",
"("... | Return DataFrame with duplicate rows removed, optionally only
considering certain columns. Indexes, including time indexes
are ignored.
Parameters
----------
subset : column label or sequence of labels, optional
Only consider certain columns for identifying duplicate... | [
"Return",
"DataFrame",
"with",
"duplicate",
"rows",
"removed",
"optionally",
"only",
"considering",
"certain",
"columns",
".",
"Indexes",
"including",
"time",
"indexes",
"are",
"ignored",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L4646-L4679 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.duplicated | def duplicated(self, subset=None, keep='first'):
"""
Return boolean Series denoting duplicate rows, optionally only
considering certain columns.
Parameters
----------
subset : column label or sequence of labels, optional
Only consider certain columns for iden... | python | def duplicated(self, subset=None, keep='first'):
"""
Return boolean Series denoting duplicate rows, optionally only
considering certain columns.
Parameters
----------
subset : column label or sequence of labels, optional
Only consider certain columns for iden... | [
"def",
"duplicated",
"(",
"self",
",",
"subset",
"=",
"None",
",",
"keep",
"=",
"'first'",
")",
":",
"from",
"pandas",
".",
"core",
".",
"sorting",
"import",
"get_group_index",
"from",
"pandas",
".",
"_libs",
".",
"hashtable",
"import",
"duplicated_int64",
... | Return boolean Series denoting duplicate rows, optionally only
considering certain columns.
Parameters
----------
subset : column label or sequence of labels, optional
Only consider certain columns for identifying duplicates, by
default use all of the columns
... | [
"Return",
"boolean",
"Series",
"denoting",
"duplicate",
"rows",
"optionally",
"only",
"considering",
"certain",
"columns",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L4681-L4732 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.nlargest | def nlargest(self, n, columns, keep='first'):
"""
Return the first `n` rows ordered by `columns` in descending order.
Return the first `n` rows with the largest values in `columns`, in
descending order. The columns that are not specified are returned as
well, but not used for or... | python | def nlargest(self, n, columns, keep='first'):
"""
Return the first `n` rows ordered by `columns` in descending order.
Return the first `n` rows with the largest values in `columns`, in
descending order. The columns that are not specified are returned as
well, but not used for or... | [
"def",
"nlargest",
"(",
"self",
",",
"n",
",",
"columns",
",",
"keep",
"=",
"'first'",
")",
":",
"return",
"algorithms",
".",
"SelectNFrame",
"(",
"self",
",",
"n",
"=",
"n",
",",
"keep",
"=",
"keep",
",",
"columns",
"=",
"columns",
")",
".",
"nlar... | Return the first `n` rows ordered by `columns` in descending order.
Return the first `n` rows with the largest values in `columns`, in
descending order. The columns that are not specified are returned as
well, but not used for ordering.
This method is equivalent to
``df.sort_va... | [
"Return",
"the",
"first",
"n",
"rows",
"ordered",
"by",
"columns",
"in",
"descending",
"order",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L4843-L4953 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.nsmallest | def nsmallest(self, n, columns, keep='first'):
"""
Return the first `n` rows ordered by `columns` in ascending order.
Return the first `n` rows with the smallest values in `columns`, in
ascending order. The columns that are not specified are returned as
well, but not used for or... | python | def nsmallest(self, n, columns, keep='first'):
"""
Return the first `n` rows ordered by `columns` in ascending order.
Return the first `n` rows with the smallest values in `columns`, in
ascending order. The columns that are not specified are returned as
well, but not used for or... | [
"def",
"nsmallest",
"(",
"self",
",",
"n",
",",
"columns",
",",
"keep",
"=",
"'first'",
")",
":",
"return",
"algorithms",
".",
"SelectNFrame",
"(",
"self",
",",
"n",
"=",
"n",
",",
"keep",
"=",
"keep",
",",
"columns",
"=",
"columns",
")",
".",
"nsm... | Return the first `n` rows ordered by `columns` in ascending order.
Return the first `n` rows with the smallest values in `columns`, in
ascending order. The columns that are not specified are returned as
well, but not used for ordering.
This method is equivalent to
``df.sort_val... | [
"Return",
"the",
"first",
"n",
"rows",
"ordered",
"by",
"columns",
"in",
"ascending",
"order",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L4955-L5055 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.swaplevel | def swaplevel(self, i=-2, j=-1, axis=0):
"""
Swap levels i and j in a MultiIndex on a particular axis.
Parameters
----------
i, j : int, string (can be mixed)
Level of index to be swapped. Can pass level name as string.
Returns
-------
DataFr... | python | def swaplevel(self, i=-2, j=-1, axis=0):
"""
Swap levels i and j in a MultiIndex on a particular axis.
Parameters
----------
i, j : int, string (can be mixed)
Level of index to be swapped. Can pass level name as string.
Returns
-------
DataFr... | [
"def",
"swaplevel",
"(",
"self",
",",
"i",
"=",
"-",
"2",
",",
"j",
"=",
"-",
"1",
",",
"axis",
"=",
"0",
")",
":",
"result",
"=",
"self",
".",
"copy",
"(",
")",
"axis",
"=",
"self",
".",
"_get_axis_number",
"(",
"axis",
")",
"if",
"axis",
"=... | Swap levels i and j in a MultiIndex on a particular axis.
Parameters
----------
i, j : int, string (can be mixed)
Level of index to be swapped. Can pass level name as string.
Returns
-------
DataFrame
.. versionchanged:: 0.18.1
The index... | [
"Swap",
"levels",
"i",
"and",
"j",
"in",
"a",
"MultiIndex",
"on",
"a",
"particular",
"axis",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L5057-L5082 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.reorder_levels | def reorder_levels(self, order, axis=0):
"""
Rearrange index levels using input order. May not drop or
duplicate levels.
Parameters
----------
order : list of int or list of str
List representing new level order. Reference level by number
(positio... | python | def reorder_levels(self, order, axis=0):
"""
Rearrange index levels using input order. May not drop or
duplicate levels.
Parameters
----------
order : list of int or list of str
List representing new level order. Reference level by number
(positio... | [
"def",
"reorder_levels",
"(",
"self",
",",
"order",
",",
"axis",
"=",
"0",
")",
":",
"axis",
"=",
"self",
".",
"_get_axis_number",
"(",
"axis",
")",
"if",
"not",
"isinstance",
"(",
"self",
".",
"_get_axis",
"(",
"axis",
")",
",",
"MultiIndex",
")",
"... | Rearrange index levels using input order. May not drop or
duplicate levels.
Parameters
----------
order : list of int or list of str
List representing new level order. Reference level by number
(position) or by key (label).
axis : int
Where to... | [
"Rearrange",
"index",
"levels",
"using",
"input",
"order",
".",
"May",
"not",
"drop",
"or",
"duplicate",
"levels",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L5084-L5112 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.combine | def combine(self, other, func, fill_value=None, overwrite=True):
"""
Perform column-wise combine with another DataFrame.
Combines a DataFrame with `other` DataFrame using `func`
to element-wise combine columns. The row and column indexes of the
resulting DataFrame will be the un... | python | def combine(self, other, func, fill_value=None, overwrite=True):
"""
Perform column-wise combine with another DataFrame.
Combines a DataFrame with `other` DataFrame using `func`
to element-wise combine columns. The row and column indexes of the
resulting DataFrame will be the un... | [
"def",
"combine",
"(",
"self",
",",
"other",
",",
"func",
",",
"fill_value",
"=",
"None",
",",
"overwrite",
"=",
"True",
")",
":",
"other_idxlen",
"=",
"len",
"(",
"other",
".",
"index",
")",
"# save for compare",
"this",
",",
"other",
"=",
"self",
"."... | Perform column-wise combine with another DataFrame.
Combines a DataFrame with `other` DataFrame using `func`
to element-wise combine columns. The row and column indexes of the
resulting DataFrame will be the union of the two.
Parameters
----------
other : DataFrame
... | [
"Perform",
"column",
"-",
"wise",
"combine",
"with",
"another",
"DataFrame",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L5164-L5330 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.combine_first | def combine_first(self, other):
"""
Update null elements with value in the same location in `other`.
Combine two DataFrame objects by filling null values in one DataFrame
with non-null values from other DataFrame. The row and column indexes
of the resulting DataFrame will be the... | python | def combine_first(self, other):
"""
Update null elements with value in the same location in `other`.
Combine two DataFrame objects by filling null values in one DataFrame
with non-null values from other DataFrame. The row and column indexes
of the resulting DataFrame will be the... | [
"def",
"combine_first",
"(",
"self",
",",
"other",
")",
":",
"import",
"pandas",
".",
"core",
".",
"computation",
".",
"expressions",
"as",
"expressions",
"def",
"extract_values",
"(",
"arr",
")",
":",
"# Does two things:",
"# 1. maybe gets the values from the Serie... | Update null elements with value in the same location in `other`.
Combine two DataFrame objects by filling null values in one DataFrame
with non-null values from other DataFrame. The row and column indexes
of the resulting DataFrame will be the union of the two.
Parameters
-----... | [
"Update",
"null",
"elements",
"with",
"value",
"in",
"the",
"same",
"location",
"in",
"other",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L5332-L5406 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.update | def update(self, other, join='left', overwrite=True, filter_func=None,
errors='ignore'):
"""
Modify in place using non-NA values from another DataFrame.
Aligns on indices. There is no return value.
Parameters
----------
other : DataFrame, or object coerci... | python | def update(self, other, join='left', overwrite=True, filter_func=None,
errors='ignore'):
"""
Modify in place using non-NA values from another DataFrame.
Aligns on indices. There is no return value.
Parameters
----------
other : DataFrame, or object coerci... | [
"def",
"update",
"(",
"self",
",",
"other",
",",
"join",
"=",
"'left'",
",",
"overwrite",
"=",
"True",
",",
"filter_func",
"=",
"None",
",",
"errors",
"=",
"'ignore'",
")",
":",
"import",
"pandas",
".",
"core",
".",
"computation",
".",
"expressions",
"... | Modify in place using non-NA values from another DataFrame.
Aligns on indices. There is no return value.
Parameters
----------
other : DataFrame, or object coercible into a DataFrame
Should have at least one matching index/column label
with the original DataFram... | [
"Modify",
"in",
"place",
"using",
"non",
"-",
"NA",
"values",
"from",
"another",
"DataFrame",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L5410-L5558 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.stack | def stack(self, level=-1, dropna=True):
"""
Stack the prescribed level(s) from columns to index.
Return a reshaped DataFrame or Series having a multi-level
index with one or more new inner-most levels compared to the current
DataFrame. The new inner-most levels are created by pi... | python | def stack(self, level=-1, dropna=True):
"""
Stack the prescribed level(s) from columns to index.
Return a reshaped DataFrame or Series having a multi-level
index with one or more new inner-most levels compared to the current
DataFrame. The new inner-most levels are created by pi... | [
"def",
"stack",
"(",
"self",
",",
"level",
"=",
"-",
"1",
",",
"dropna",
"=",
"True",
")",
":",
"from",
"pandas",
".",
"core",
".",
"reshape",
".",
"reshape",
"import",
"stack",
",",
"stack_multiple",
"if",
"isinstance",
"(",
"level",
",",
"(",
"tupl... | Stack the prescribed level(s) from columns to index.
Return a reshaped DataFrame or Series having a multi-level
index with one or more new inner-most levels compared to the current
DataFrame. The new inner-most levels are created by pivoting the
columns of the current dataframe:
... | [
"Stack",
"the",
"prescribed",
"level",
"(",
"s",
")",
"from",
"columns",
"to",
"index",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L5808-L5976 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.unstack | def unstack(self, level=-1, fill_value=None):
"""
Pivot a level of the (necessarily hierarchical) index labels, returning
a DataFrame having a new level of column labels whose inner-most level
consists of the pivoted index labels.
If the index is not a MultiIndex, the output wil... | python | def unstack(self, level=-1, fill_value=None):
"""
Pivot a level of the (necessarily hierarchical) index labels, returning
a DataFrame having a new level of column labels whose inner-most level
consists of the pivoted index labels.
If the index is not a MultiIndex, the output wil... | [
"def",
"unstack",
"(",
"self",
",",
"level",
"=",
"-",
"1",
",",
"fill_value",
"=",
"None",
")",
":",
"from",
"pandas",
".",
"core",
".",
"reshape",
".",
"reshape",
"import",
"unstack",
"return",
"unstack",
"(",
"self",
",",
"level",
",",
"fill_value",... | Pivot a level of the (necessarily hierarchical) index labels, returning
a DataFrame having a new level of column labels whose inner-most level
consists of the pivoted index labels.
If the index is not a MultiIndex, the output will be a Series
(the analogue of stack when the columns are ... | [
"Pivot",
"a",
"level",
"of",
"the",
"(",
"necessarily",
"hierarchical",
")",
"index",
"labels",
"returning",
"a",
"DataFrame",
"having",
"a",
"new",
"level",
"of",
"column",
"labels",
"whose",
"inner",
"-",
"most",
"level",
"consists",
"of",
"the",
"pivoted"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L5978-L6039 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.diff | def diff(self, periods=1, axis=0):
"""
First discrete difference of element.
Calculates the difference of a DataFrame element compared with another
element in the DataFrame (default is the element in the same column
of the previous row).
Parameters
----------
... | python | def diff(self, periods=1, axis=0):
"""
First discrete difference of element.
Calculates the difference of a DataFrame element compared with another
element in the DataFrame (default is the element in the same column
of the previous row).
Parameters
----------
... | [
"def",
"diff",
"(",
"self",
",",
"periods",
"=",
"1",
",",
"axis",
"=",
"0",
")",
":",
"bm_axis",
"=",
"self",
".",
"_get_block_manager_axis",
"(",
"axis",
")",
"new_data",
"=",
"self",
".",
"_data",
".",
"diff",
"(",
"n",
"=",
"periods",
",",
"axi... | First discrete difference of element.
Calculates the difference of a DataFrame element compared with another
element in the DataFrame (default is the element in the same column
of the previous row).
Parameters
----------
periods : int, default 1
Periods to s... | [
"First",
"discrete",
"difference",
"of",
"element",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L6145-L6234 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame._gotitem | def _gotitem(self,
key: Union[str, List[str]],
ndim: int,
subset: Optional[Union[Series, ABCDataFrame]] = None,
) -> Union[Series, ABCDataFrame]:
"""
Sub-classes to define. Return a sliced object.
Parameters
----------
... | python | def _gotitem(self,
key: Union[str, List[str]],
ndim: int,
subset: Optional[Union[Series, ABCDataFrame]] = None,
) -> Union[Series, ABCDataFrame]:
"""
Sub-classes to define. Return a sliced object.
Parameters
----------
... | [
"def",
"_gotitem",
"(",
"self",
",",
"key",
":",
"Union",
"[",
"str",
",",
"List",
"[",
"str",
"]",
"]",
",",
"ndim",
":",
"int",
",",
"subset",
":",
"Optional",
"[",
"Union",
"[",
"Series",
",",
"ABCDataFrame",
"]",
"]",
"=",
"None",
",",
")",
... | Sub-classes to define. Return a sliced object.
Parameters
----------
key : string / list of selections
ndim : 1,2
requested ndim of result
subset : object, default None
subset to act on | [
"Sub",
"-",
"classes",
"to",
"define",
".",
"Return",
"a",
"sliced",
"object",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L6239-L6261 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.apply | def apply(self, func, axis=0, broadcast=None, raw=False, reduce=None,
result_type=None, args=(), **kwds):
"""
Apply a function along an axis of the DataFrame.
Objects passed to the function are Series objects whose index is
either the DataFrame's index (``axis=0``) or the ... | python | def apply(self, func, axis=0, broadcast=None, raw=False, reduce=None,
result_type=None, args=(), **kwds):
"""
Apply a function along an axis of the DataFrame.
Objects passed to the function are Series objects whose index is
either the DataFrame's index (``axis=0``) or the ... | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"axis",
"=",
"0",
",",
"broadcast",
"=",
"None",
",",
"raw",
"=",
"False",
",",
"reduce",
"=",
"None",
",",
"result_type",
"=",
"None",
",",
"args",
"=",
"(",
")",
",",
"*",
"*",
"kwds",
")",
":",
... | Apply a function along an axis of the DataFrame.
Objects passed to the function are Series objects whose index is
either the DataFrame's index (``axis=0``) or the DataFrame's columns
(``axis=1``). By default (``result_type=None``), the final return type
is inferred from the return type ... | [
"Apply",
"a",
"function",
"along",
"an",
"axis",
"of",
"the",
"DataFrame",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L6355-L6534 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.applymap | def applymap(self, func):
"""
Apply a function to a Dataframe elementwise.
This method applies a function that accepts and returns a scalar
to every element of a DataFrame.
Parameters
----------
func : callable
Python function, returns a single value... | python | def applymap(self, func):
"""
Apply a function to a Dataframe elementwise.
This method applies a function that accepts and returns a scalar
to every element of a DataFrame.
Parameters
----------
func : callable
Python function, returns a single value... | [
"def",
"applymap",
"(",
"self",
",",
"func",
")",
":",
"# if we have a dtype == 'M8[ns]', provide boxed values",
"def",
"infer",
"(",
"x",
")",
":",
"if",
"x",
".",
"empty",
":",
"return",
"lib",
".",
"map_infer",
"(",
"x",
",",
"func",
")",
"return",
"lib... | Apply a function to a Dataframe elementwise.
This method applies a function that accepts and returns a scalar
to every element of a DataFrame.
Parameters
----------
func : callable
Python function, returns a single value from a single value.
Returns
... | [
"Apply",
"a",
"function",
"to",
"a",
"Dataframe",
"elementwise",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L6536-L6600 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.append | def append(self, other, ignore_index=False,
verify_integrity=False, sort=None):
"""
Append rows of `other` to the end of caller, returning a new object.
Columns in `other` that are not in the caller are added as new columns.
Parameters
----------
other : ... | python | def append(self, other, ignore_index=False,
verify_integrity=False, sort=None):
"""
Append rows of `other` to the end of caller, returning a new object.
Columns in `other` that are not in the caller are added as new columns.
Parameters
----------
other : ... | [
"def",
"append",
"(",
"self",
",",
"other",
",",
"ignore_index",
"=",
"False",
",",
"verify_integrity",
"=",
"False",
",",
"sort",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"(",
"Series",
",",
"dict",
")",
")",
":",
"if",
"isinsta... | Append rows of `other` to the end of caller, returning a new object.
Columns in `other` that are not in the caller are added as new columns.
Parameters
----------
other : DataFrame or Series/dict-like object, or list of these
The data to append.
ignore_index : boole... | [
"Append",
"rows",
"of",
"other",
"to",
"the",
"end",
"of",
"caller",
"returning",
"a",
"new",
"object",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L6605-L6739 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.join | def join(self, other, on=None, how='left', lsuffix='', rsuffix='',
sort=False):
"""
Join columns of another DataFrame.
Join columns with `other` DataFrame either on index or on a key
column. Efficiently join multiple DataFrame objects by index at once by
passing a l... | python | def join(self, other, on=None, how='left', lsuffix='', rsuffix='',
sort=False):
"""
Join columns of another DataFrame.
Join columns with `other` DataFrame either on index or on a key
column. Efficiently join multiple DataFrame objects by index at once by
passing a l... | [
"def",
"join",
"(",
"self",
",",
"other",
",",
"on",
"=",
"None",
",",
"how",
"=",
"'left'",
",",
"lsuffix",
"=",
"''",
",",
"rsuffix",
"=",
"''",
",",
"sort",
"=",
"False",
")",
":",
"# For SparseDataFrame's benefit",
"return",
"self",
".",
"_join_com... | Join columns of another DataFrame.
Join columns with `other` DataFrame either on index or on a key
column. Efficiently join multiple DataFrame objects by index at once by
passing a list.
Parameters
----------
other : DataFrame, Series, or list of DataFrame
I... | [
"Join",
"columns",
"of",
"another",
"DataFrame",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L6741-L6862 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.round | def round(self, decimals=0, *args, **kwargs):
"""
Round a DataFrame to a variable number of decimal places.
Parameters
----------
decimals : int, dict, Series
Number of decimal places to round each column to. If an int is
given, round each column to the s... | python | def round(self, decimals=0, *args, **kwargs):
"""
Round a DataFrame to a variable number of decimal places.
Parameters
----------
decimals : int, dict, Series
Number of decimal places to round each column to. If an int is
given, round each column to the s... | [
"def",
"round",
"(",
"self",
",",
"decimals",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"pandas",
".",
"core",
".",
"reshape",
".",
"concat",
"import",
"concat",
"def",
"_dict_round",
"(",
"df",
",",
"decimals",
")",
":... | Round a DataFrame to a variable number of decimal places.
Parameters
----------
decimals : int, dict, Series
Number of decimal places to round each column to. If an int is
given, round each column to the same number of places.
Otherwise dict and Series round ... | [
"Round",
"a",
"DataFrame",
"to",
"a",
"variable",
"number",
"of",
"decimal",
"places",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L6917-L7028 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.corr | def corr(self, method='pearson', min_periods=1):
"""
Compute pairwise correlation of columns, excluding NA/null values.
Parameters
----------
method : {'pearson', 'kendall', 'spearman'} or callable
* pearson : standard correlation coefficient
* kendall : ... | python | def corr(self, method='pearson', min_periods=1):
"""
Compute pairwise correlation of columns, excluding NA/null values.
Parameters
----------
method : {'pearson', 'kendall', 'spearman'} or callable
* pearson : standard correlation coefficient
* kendall : ... | [
"def",
"corr",
"(",
"self",
",",
"method",
"=",
"'pearson'",
",",
"min_periods",
"=",
"1",
")",
":",
"numeric_df",
"=",
"self",
".",
"_get_numeric_data",
"(",
")",
"cols",
"=",
"numeric_df",
".",
"columns",
"idx",
"=",
"cols",
".",
"copy",
"(",
")",
... | Compute pairwise correlation of columns, excluding NA/null values.
Parameters
----------
method : {'pearson', 'kendall', 'spearman'} or callable
* pearson : standard correlation coefficient
* kendall : Kendall Tau correlation coefficient
* spearman : Spearman... | [
"Compute",
"pairwise",
"correlation",
"of",
"columns",
"excluding",
"NA",
"/",
"null",
"values",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7033-L7115 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.cov | def cov(self, min_periods=None):
"""
Compute pairwise covariance of columns, excluding NA/null values.
Compute the pairwise covariance among the series of a DataFrame.
The returned data frame is the `covariance matrix
<https://en.wikipedia.org/wiki/Covariance_matrix>`__ of the c... | python | def cov(self, min_periods=None):
"""
Compute pairwise covariance of columns, excluding NA/null values.
Compute the pairwise covariance among the series of a DataFrame.
The returned data frame is the `covariance matrix
<https://en.wikipedia.org/wiki/Covariance_matrix>`__ of the c... | [
"def",
"cov",
"(",
"self",
",",
"min_periods",
"=",
"None",
")",
":",
"numeric_df",
"=",
"self",
".",
"_get_numeric_data",
"(",
")",
"cols",
"=",
"numeric_df",
".",
"columns",
"idx",
"=",
"cols",
".",
"copy",
"(",
")",
"mat",
"=",
"numeric_df",
".",
... | Compute pairwise covariance of columns, excluding NA/null values.
Compute the pairwise covariance among the series of a DataFrame.
The returned data frame is the `covariance matrix
<https://en.wikipedia.org/wiki/Covariance_matrix>`__ of the columns
of the DataFrame.
Both NA and... | [
"Compute",
"pairwise",
"covariance",
"of",
"columns",
"excluding",
"NA",
"/",
"null",
"values",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7117-L7226 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.corrwith | def corrwith(self, other, axis=0, drop=False, method='pearson'):
"""
Compute pairwise correlation between rows or columns of DataFrame
with rows or columns of Series or DataFrame. DataFrames are first
aligned along both axes before computing the correlations.
Parameters
... | python | def corrwith(self, other, axis=0, drop=False, method='pearson'):
"""
Compute pairwise correlation between rows or columns of DataFrame
with rows or columns of Series or DataFrame. DataFrames are first
aligned along both axes before computing the correlations.
Parameters
... | [
"def",
"corrwith",
"(",
"self",
",",
"other",
",",
"axis",
"=",
"0",
",",
"drop",
"=",
"False",
",",
"method",
"=",
"'pearson'",
")",
":",
"axis",
"=",
"self",
".",
"_get_axis_number",
"(",
"axis",
")",
"this",
"=",
"self",
".",
"_get_numeric_data",
... | Compute pairwise correlation between rows or columns of DataFrame
with rows or columns of Series or DataFrame. DataFrames are first
aligned along both axes before computing the correlations.
Parameters
----------
other : DataFrame, Series
Object with which to comput... | [
"Compute",
"pairwise",
"correlation",
"between",
"rows",
"or",
"columns",
"of",
"DataFrame",
"with",
"rows",
"or",
"columns",
"of",
"Series",
"or",
"DataFrame",
".",
"DataFrames",
"are",
"first",
"aligned",
"along",
"both",
"axes",
"before",
"computing",
"the",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7228-L7314 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.count | def count(self, axis=0, level=None, numeric_only=False):
"""
Count non-NA cells for each column or row.
The values `None`, `NaN`, `NaT`, and optionally `numpy.inf` (depending
on `pandas.options.mode.use_inf_as_na`) are considered NA.
Parameters
----------
axis :... | python | def count(self, axis=0, level=None, numeric_only=False):
"""
Count non-NA cells for each column or row.
The values `None`, `NaN`, `NaT`, and optionally `numpy.inf` (depending
on `pandas.options.mode.use_inf_as_na`) are considered NA.
Parameters
----------
axis :... | [
"def",
"count",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"level",
"=",
"None",
",",
"numeric_only",
"=",
"False",
")",
":",
"axis",
"=",
"self",
".",
"_get_axis_number",
"(",
"axis",
")",
"if",
"level",
"is",
"not",
"None",
":",
"return",
"self",
"... | Count non-NA cells for each column or row.
The values `None`, `NaN`, `NaT`, and optionally `numpy.inf` (depending
on `pandas.options.mode.use_inf_as_na`) are considered NA.
Parameters
----------
axis : {0 or 'index', 1 or 'columns'}, default 0
If 0 or 'index' counts... | [
"Count",
"non",
"-",
"NA",
"cells",
"for",
"each",
"column",
"or",
"row",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7319-L7419 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.nunique | def nunique(self, axis=0, dropna=True):
"""
Count distinct observations over requested axis.
Return Series with number of distinct observations. Can ignore NaN
values.
.. versionadded:: 0.20.0
Parameters
----------
axis : {0 or 'index', 1 or 'columns'},... | python | def nunique(self, axis=0, dropna=True):
"""
Count distinct observations over requested axis.
Return Series with number of distinct observations. Can ignore NaN
values.
.. versionadded:: 0.20.0
Parameters
----------
axis : {0 or 'index', 1 or 'columns'},... | [
"def",
"nunique",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"dropna",
"=",
"True",
")",
":",
"return",
"self",
".",
"apply",
"(",
"Series",
".",
"nunique",
",",
"axis",
"=",
"axis",
",",
"dropna",
"=",
"dropna",
")"
] | Count distinct observations over requested axis.
Return Series with number of distinct observations. Can ignore NaN
values.
.. versionadded:: 0.20.0
Parameters
----------
axis : {0 or 'index', 1 or 'columns'}, default 0
The axis to use. 0 or 'index' for row... | [
"Count",
"distinct",
"observations",
"over",
"requested",
"axis",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7565-L7605 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.idxmin | def idxmin(self, axis=0, skipna=True):
"""
Return index of first occurrence of minimum over requested axis.
NA/null values are excluded.
Parameters
----------
axis : {0 or 'index', 1 or 'columns'}, default 0
0 or 'index' for row-wise, 1 or 'columns' for colum... | python | def idxmin(self, axis=0, skipna=True):
"""
Return index of first occurrence of minimum over requested axis.
NA/null values are excluded.
Parameters
----------
axis : {0 or 'index', 1 or 'columns'}, default 0
0 or 'index' for row-wise, 1 or 'columns' for colum... | [
"def",
"idxmin",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"skipna",
"=",
"True",
")",
":",
"axis",
"=",
"self",
".",
"_get_axis_number",
"(",
"axis",
")",
"indices",
"=",
"nanops",
".",
"nanargmin",
"(",
"self",
".",
"values",
",",
"axis",
"=",
"ax... | Return index of first occurrence of minimum over requested axis.
NA/null values are excluded.
Parameters
----------
axis : {0 or 'index', 1 or 'columns'}, default 0
0 or 'index' for row-wise, 1 or 'columns' for column-wise
skipna : boolean, default True
E... | [
"Return",
"index",
"of",
"first",
"occurrence",
"of",
"minimum",
"over",
"requested",
"axis",
".",
"NA",
"/",
"null",
"values",
"are",
"excluded",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7607-L7642 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame._get_agg_axis | def _get_agg_axis(self, axis_num):
"""
Let's be explicit about this.
"""
if axis_num == 0:
return self.columns
elif axis_num == 1:
return self.index
else:
raise ValueError('Axis must be 0 or 1 (got %r)' % axis_num) | python | def _get_agg_axis(self, axis_num):
"""
Let's be explicit about this.
"""
if axis_num == 0:
return self.columns
elif axis_num == 1:
return self.index
else:
raise ValueError('Axis must be 0 or 1 (got %r)' % axis_num) | [
"def",
"_get_agg_axis",
"(",
"self",
",",
"axis_num",
")",
":",
"if",
"axis_num",
"==",
"0",
":",
"return",
"self",
".",
"columns",
"elif",
"axis_num",
"==",
"1",
":",
"return",
"self",
".",
"index",
"else",
":",
"raise",
"ValueError",
"(",
"'Axis must b... | Let's be explicit about this. | [
"Let",
"s",
"be",
"explicit",
"about",
"this",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7681-L7690 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.mode | def mode(self, axis=0, numeric_only=False, dropna=True):
"""
Get the mode(s) of each element along the selected axis.
The mode of a set of values is the value that appears most often.
It can be multiple values.
Parameters
----------
axis : {0 or 'index', 1 or 'c... | python | def mode(self, axis=0, numeric_only=False, dropna=True):
"""
Get the mode(s) of each element along the selected axis.
The mode of a set of values is the value that appears most often.
It can be multiple values.
Parameters
----------
axis : {0 or 'index', 1 or 'c... | [
"def",
"mode",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"numeric_only",
"=",
"False",
",",
"dropna",
"=",
"True",
")",
":",
"data",
"=",
"self",
"if",
"not",
"numeric_only",
"else",
"self",
".",
"_get_numeric_data",
"(",
")",
"def",
"f",
"(",
"s",
... | Get the mode(s) of each element along the selected axis.
The mode of a set of values is the value that appears most often.
It can be multiple values.
Parameters
----------
axis : {0 or 'index', 1 or 'columns'}, default 0
The axis to iterate over while searching for ... | [
"Get",
"the",
"mode",
"(",
"s",
")",
"of",
"each",
"element",
"along",
"the",
"selected",
"axis",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7692-L7776 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.quantile | def quantile(self, q=0.5, axis=0, numeric_only=True,
interpolation='linear'):
"""
Return values at the given quantile over requested axis.
Parameters
----------
q : float or array-like, default 0.5 (50% quantile)
Value between 0 <= q <= 1, the quanti... | python | def quantile(self, q=0.5, axis=0, numeric_only=True,
interpolation='linear'):
"""
Return values at the given quantile over requested axis.
Parameters
----------
q : float or array-like, default 0.5 (50% quantile)
Value between 0 <= q <= 1, the quanti... | [
"def",
"quantile",
"(",
"self",
",",
"q",
"=",
"0.5",
",",
"axis",
"=",
"0",
",",
"numeric_only",
"=",
"True",
",",
"interpolation",
"=",
"'linear'",
")",
":",
"self",
".",
"_check_percentile",
"(",
"q",
")",
"data",
"=",
"self",
".",
"_get_numeric_dat... | Return values at the given quantile over requested axis.
Parameters
----------
q : float or array-like, default 0.5 (50% quantile)
Value between 0 <= q <= 1, the quantile(s) to compute.
axis : {0, 1, 'index', 'columns'} (default 0)
Equals 0 or 'index' for row-wis... | [
"Return",
"values",
"at",
"the",
"given",
"quantile",
"over",
"requested",
"axis",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7778-L7869 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.to_timestamp | def to_timestamp(self, freq=None, how='start', axis=0, copy=True):
"""
Cast to DatetimeIndex of timestamps, at *beginning* of period.
Parameters
----------
freq : str, default frequency of PeriodIndex
Desired frequency.
how : {'s', 'e', 'start', 'end'}
... | python | def to_timestamp(self, freq=None, how='start', axis=0, copy=True):
"""
Cast to DatetimeIndex of timestamps, at *beginning* of period.
Parameters
----------
freq : str, default frequency of PeriodIndex
Desired frequency.
how : {'s', 'e', 'start', 'end'}
... | [
"def",
"to_timestamp",
"(",
"self",
",",
"freq",
"=",
"None",
",",
"how",
"=",
"'start'",
",",
"axis",
"=",
"0",
",",
"copy",
"=",
"True",
")",
":",
"new_data",
"=",
"self",
".",
"_data",
"if",
"copy",
":",
"new_data",
"=",
"new_data",
".",
"copy",... | Cast to DatetimeIndex of timestamps, at *beginning* of period.
Parameters
----------
freq : str, default frequency of PeriodIndex
Desired frequency.
how : {'s', 'e', 'start', 'end'}
Convention for converting period to timestamp; start of period
vs. en... | [
"Cast",
"to",
"DatetimeIndex",
"of",
"timestamps",
"at",
"*",
"beginning",
"*",
"of",
"period",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7871-L7904 | train |
pandas-dev/pandas | pandas/core/frame.py | DataFrame.isin | def isin(self, values):
"""
Whether each element in the DataFrame is contained in values.
Parameters
----------
values : iterable, Series, DataFrame or dict
The result will only be true at a location if all the
labels match. If `values` is a Series, that'... | python | def isin(self, values):
"""
Whether each element in the DataFrame is contained in values.
Parameters
----------
values : iterable, Series, DataFrame or dict
The result will only be true at a location if all the
labels match. If `values` is a Series, that'... | [
"def",
"isin",
"(",
"self",
",",
"values",
")",
":",
"if",
"isinstance",
"(",
"values",
",",
"dict",
")",
":",
"from",
"pandas",
".",
"core",
".",
"reshape",
".",
"concat",
"import",
"concat",
"values",
"=",
"collections",
".",
"defaultdict",
"(",
"lis... | Whether each element in the DataFrame is contained in values.
Parameters
----------
values : iterable, Series, DataFrame or dict
The result will only be true at a location if all the
labels match. If `values` is a Series, that's the index. If
`values` is a di... | [
"Whether",
"each",
"element",
"in",
"the",
"DataFrame",
"is",
"contained",
"in",
"values",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7939-L8026 | train |
pandas-dev/pandas | pandas/core/arrays/integer.py | integer_array | def integer_array(values, dtype=None, copy=False):
"""
Infer and return an integer array of the values.
Parameters
----------
values : 1D list-like
dtype : dtype, optional
dtype to coerce
copy : boolean, default False
Returns
-------
IntegerArray
Raises
------
... | python | def integer_array(values, dtype=None, copy=False):
"""
Infer and return an integer array of the values.
Parameters
----------
values : 1D list-like
dtype : dtype, optional
dtype to coerce
copy : boolean, default False
Returns
-------
IntegerArray
Raises
------
... | [
"def",
"integer_array",
"(",
"values",
",",
"dtype",
"=",
"None",
",",
"copy",
"=",
"False",
")",
":",
"values",
",",
"mask",
"=",
"coerce_to_array",
"(",
"values",
",",
"dtype",
"=",
"dtype",
",",
"copy",
"=",
"copy",
")",
"return",
"IntegerArray",
"(... | Infer and return an integer array of the values.
Parameters
----------
values : 1D list-like
dtype : dtype, optional
dtype to coerce
copy : boolean, default False
Returns
-------
IntegerArray
Raises
------
TypeError if incompatible types | [
"Infer",
"and",
"return",
"an",
"integer",
"array",
"of",
"the",
"values",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L92-L112 | train |
pandas-dev/pandas | pandas/core/arrays/integer.py | safe_cast | def safe_cast(values, dtype, copy):
"""
Safely cast the values to the dtype if they
are equivalent, meaning floats must be equivalent to the
ints.
"""
try:
return values.astype(dtype, casting='safe', copy=copy)
except TypeError:
casted = values.astype(dtype, copy=copy)
... | python | def safe_cast(values, dtype, copy):
"""
Safely cast the values to the dtype if they
are equivalent, meaning floats must be equivalent to the
ints.
"""
try:
return values.astype(dtype, casting='safe', copy=copy)
except TypeError:
casted = values.astype(dtype, copy=copy)
... | [
"def",
"safe_cast",
"(",
"values",
",",
"dtype",
",",
"copy",
")",
":",
"try",
":",
"return",
"values",
".",
"astype",
"(",
"dtype",
",",
"casting",
"=",
"'safe'",
",",
"copy",
"=",
"copy",
")",
"except",
"TypeError",
":",
"casted",
"=",
"values",
".... | Safely cast the values to the dtype if they
are equivalent, meaning floats must be equivalent to the
ints. | [
"Safely",
"cast",
"the",
"values",
"to",
"the",
"dtype",
"if",
"they",
"are",
"equivalent",
"meaning",
"floats",
"must",
"be",
"equivalent",
"to",
"the",
"ints",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L115-L132 | train |
pandas-dev/pandas | pandas/core/arrays/integer.py | coerce_to_array | def coerce_to_array(values, dtype, mask=None, copy=False):
"""
Coerce the input values array to numpy arrays with a mask
Parameters
----------
values : 1D list-like
dtype : integer dtype
mask : boolean 1D array, optional
copy : boolean, default False
if True, copy the input
... | python | def coerce_to_array(values, dtype, mask=None, copy=False):
"""
Coerce the input values array to numpy arrays with a mask
Parameters
----------
values : 1D list-like
dtype : integer dtype
mask : boolean 1D array, optional
copy : boolean, default False
if True, copy the input
... | [
"def",
"coerce_to_array",
"(",
"values",
",",
"dtype",
",",
"mask",
"=",
"None",
",",
"copy",
"=",
"False",
")",
":",
"# if values is integer numpy array, preserve it's dtype",
"if",
"dtype",
"is",
"None",
"and",
"hasattr",
"(",
"values",
",",
"'dtype'",
")",
... | Coerce the input values array to numpy arrays with a mask
Parameters
----------
values : 1D list-like
dtype : integer dtype
mask : boolean 1D array, optional
copy : boolean, default False
if True, copy the input
Returns
-------
tuple of (values, mask) | [
"Coerce",
"the",
"input",
"values",
"array",
"to",
"numpy",
"arrays",
"with",
"a",
"mask"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L135-L221 | train |
pandas-dev/pandas | pandas/core/arrays/integer.py | _IntegerDtype.construct_from_string | def construct_from_string(cls, string):
"""
Construction from a string, raise a TypeError if not
possible
"""
if string == cls.name:
return cls()
raise TypeError("Cannot construct a '{}' from "
"'{}'".format(cls, string)) | python | def construct_from_string(cls, string):
"""
Construction from a string, raise a TypeError if not
possible
"""
if string == cls.name:
return cls()
raise TypeError("Cannot construct a '{}' from "
"'{}'".format(cls, string)) | [
"def",
"construct_from_string",
"(",
"cls",
",",
"string",
")",
":",
"if",
"string",
"==",
"cls",
".",
"name",
":",
"return",
"cls",
"(",
")",
"raise",
"TypeError",
"(",
"\"Cannot construct a '{}' from \"",
"\"'{}'\"",
".",
"format",
"(",
"cls",
",",
"string... | Construction from a string, raise a TypeError if not
possible | [
"Construction",
"from",
"a",
"string",
"raise",
"a",
"TypeError",
"if",
"not",
"possible"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L81-L89 | train |
pandas-dev/pandas | pandas/core/arrays/integer.py | IntegerArray._coerce_to_ndarray | def _coerce_to_ndarray(self):
"""
coerce to an ndarary of object dtype
"""
# TODO(jreback) make this better
data = self._data.astype(object)
data[self._mask] = self._na_value
return data | python | def _coerce_to_ndarray(self):
"""
coerce to an ndarary of object dtype
"""
# TODO(jreback) make this better
data = self._data.astype(object)
data[self._mask] = self._na_value
return data | [
"def",
"_coerce_to_ndarray",
"(",
"self",
")",
":",
"# TODO(jreback) make this better",
"data",
"=",
"self",
".",
"_data",
".",
"astype",
"(",
"object",
")",
"data",
"[",
"self",
".",
"_mask",
"]",
"=",
"self",
".",
"_na_value",
"return",
"data"
] | coerce to an ndarary of object dtype | [
"coerce",
"to",
"an",
"ndarary",
"of",
"object",
"dtype"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L328-L336 | train |
pandas-dev/pandas | pandas/core/arrays/integer.py | IntegerArray.astype | def astype(self, dtype, copy=True):
"""
Cast to a NumPy array or IntegerArray with 'dtype'.
Parameters
----------
dtype : str or dtype
Typecode or data-type to which the array is cast.
copy : bool, default True
Whether to copy the data, even if no... | python | def astype(self, dtype, copy=True):
"""
Cast to a NumPy array or IntegerArray with 'dtype'.
Parameters
----------
dtype : str or dtype
Typecode or data-type to which the array is cast.
copy : bool, default True
Whether to copy the data, even if no... | [
"def",
"astype",
"(",
"self",
",",
"dtype",
",",
"copy",
"=",
"True",
")",
":",
"# if we are astyping to an existing IntegerDtype we can fastpath",
"if",
"isinstance",
"(",
"dtype",
",",
"_IntegerDtype",
")",
":",
"result",
"=",
"self",
".",
"_data",
".",
"astyp... | Cast to a NumPy array or IntegerArray with 'dtype'.
Parameters
----------
dtype : str or dtype
Typecode or data-type to which the array is cast.
copy : bool, default True
Whether to copy the data, even if not necessary. If False,
a copy is made only i... | [
"Cast",
"to",
"a",
"NumPy",
"array",
"or",
"IntegerArray",
"with",
"dtype",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L420-L452 | train |
pandas-dev/pandas | pandas/core/arrays/integer.py | IntegerArray.value_counts | def value_counts(self, dropna=True):
"""
Returns a Series containing counts of each category.
Every category will have an entry, even those with a count of 0.
Parameters
----------
dropna : boolean, default True
Don't include counts of NaN.
Returns
... | python | def value_counts(self, dropna=True):
"""
Returns a Series containing counts of each category.
Every category will have an entry, even those with a count of 0.
Parameters
----------
dropna : boolean, default True
Don't include counts of NaN.
Returns
... | [
"def",
"value_counts",
"(",
"self",
",",
"dropna",
"=",
"True",
")",
":",
"from",
"pandas",
"import",
"Index",
",",
"Series",
"# compute counts on the data with no nans",
"data",
"=",
"self",
".",
"_data",
"[",
"~",
"self",
".",
"_mask",
"]",
"value_counts",
... | Returns a Series containing counts of each category.
Every category will have an entry, even those with a count of 0.
Parameters
----------
dropna : boolean, default True
Don't include counts of NaN.
Returns
-------
counts : Series
See Also... | [
"Returns",
"a",
"Series",
"containing",
"counts",
"of",
"each",
"category",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L465-L509 | train |
pandas-dev/pandas | pandas/core/arrays/integer.py | IntegerArray._values_for_argsort | def _values_for_argsort(self) -> np.ndarray:
"""Return values for sorting.
Returns
-------
ndarray
The transformed values should maintain the ordering between values
within the array.
See Also
--------
ExtensionArray.argsort
"""
... | python | def _values_for_argsort(self) -> np.ndarray:
"""Return values for sorting.
Returns
-------
ndarray
The transformed values should maintain the ordering between values
within the array.
See Also
--------
ExtensionArray.argsort
"""
... | [
"def",
"_values_for_argsort",
"(",
"self",
")",
"->",
"np",
".",
"ndarray",
":",
"data",
"=",
"self",
".",
"_data",
".",
"copy",
"(",
")",
"data",
"[",
"self",
".",
"_mask",
"]",
"=",
"data",
".",
"min",
"(",
")",
"-",
"1",
"return",
"data"
] | Return values for sorting.
Returns
-------
ndarray
The transformed values should maintain the ordering between values
within the array.
See Also
--------
ExtensionArray.argsort | [
"Return",
"values",
"for",
"sorting",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L511-L526 | train |
pandas-dev/pandas | pandas/core/arrays/integer.py | IntegerArray._maybe_mask_result | def _maybe_mask_result(self, result, mask, other, op_name):
"""
Parameters
----------
result : array-like
mask : array-like bool
other : scalar or array-like
op_name : str
"""
# may need to fill infs
# and mask wraparound
if is_flo... | python | def _maybe_mask_result(self, result, mask, other, op_name):
"""
Parameters
----------
result : array-like
mask : array-like bool
other : scalar or array-like
op_name : str
"""
# may need to fill infs
# and mask wraparound
if is_flo... | [
"def",
"_maybe_mask_result",
"(",
"self",
",",
"result",
",",
"mask",
",",
"other",
",",
"op_name",
")",
":",
"# may need to fill infs",
"# and mask wraparound",
"if",
"is_float_dtype",
"(",
"result",
")",
":",
"mask",
"|=",
"(",
"result",
"==",
"np",
".",
"... | Parameters
----------
result : array-like
mask : array-like bool
other : scalar or array-like
op_name : str | [
"Parameters",
"----------",
"result",
":",
"array",
"-",
"like",
"mask",
":",
"array",
"-",
"like",
"bool",
"other",
":",
"scalar",
"or",
"array",
"-",
"like",
"op_name",
":",
"str"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L593-L616 | train |
pandas-dev/pandas | pandas/core/indexing.py | length_of_indexer | def length_of_indexer(indexer, target=None):
"""
return the length of a single non-tuple indexer which could be a slice
"""
if target is not None and isinstance(indexer, slice):
target_len = len(target)
start = indexer.start
stop = indexer.stop
step = indexer.step
... | python | def length_of_indexer(indexer, target=None):
"""
return the length of a single non-tuple indexer which could be a slice
"""
if target is not None and isinstance(indexer, slice):
target_len = len(target)
start = indexer.start
stop = indexer.stop
step = indexer.step
... | [
"def",
"length_of_indexer",
"(",
"indexer",
",",
"target",
"=",
"None",
")",
":",
"if",
"target",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"indexer",
",",
"slice",
")",
":",
"target_len",
"=",
"len",
"(",
"target",
")",
"start",
"=",
"indexer",
"... | return the length of a single non-tuple indexer which could be a slice | [
"return",
"the",
"length",
"of",
"a",
"single",
"non",
"-",
"tuple",
"indexer",
"which",
"could",
"be",
"a",
"slice"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2431-L2457 | train |
pandas-dev/pandas | pandas/core/indexing.py | convert_to_index_sliceable | def convert_to_index_sliceable(obj, key):
"""
if we are index sliceable, then return my slicer, otherwise return None
"""
idx = obj.index
if isinstance(key, slice):
return idx._convert_slice_indexer(key, kind='getitem')
elif isinstance(key, str):
# we are an actual column
... | python | def convert_to_index_sliceable(obj, key):
"""
if we are index sliceable, then return my slicer, otherwise return None
"""
idx = obj.index
if isinstance(key, slice):
return idx._convert_slice_indexer(key, kind='getitem')
elif isinstance(key, str):
# we are an actual column
... | [
"def",
"convert_to_index_sliceable",
"(",
"obj",
",",
"key",
")",
":",
"idx",
"=",
"obj",
".",
"index",
"if",
"isinstance",
"(",
"key",
",",
"slice",
")",
":",
"return",
"idx",
".",
"_convert_slice_indexer",
"(",
"key",
",",
"kind",
"=",
"'getitem'",
")"... | if we are index sliceable, then return my slicer, otherwise return None | [
"if",
"we",
"are",
"index",
"sliceable",
"then",
"return",
"my",
"slicer",
"otherwise",
"return",
"None"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2460-L2482 | train |
pandas-dev/pandas | pandas/core/indexing.py | check_setitem_lengths | def check_setitem_lengths(indexer, value, values):
"""
Validate that value and indexer are the same length.
An special-case is allowed for when the indexer is a boolean array
and the number of true values equals the length of ``value``. In
this case, no exception is raised.
Parameters
----... | python | def check_setitem_lengths(indexer, value, values):
"""
Validate that value and indexer are the same length.
An special-case is allowed for when the indexer is a boolean array
and the number of true values equals the length of ``value``. In
this case, no exception is raised.
Parameters
----... | [
"def",
"check_setitem_lengths",
"(",
"indexer",
",",
"value",
",",
"values",
")",
":",
"# boolean with truth values == len of the value is ok too",
"if",
"isinstance",
"(",
"indexer",
",",
"(",
"np",
".",
"ndarray",
",",
"list",
")",
")",
":",
"if",
"is_list_like"... | Validate that value and indexer are the same length.
An special-case is allowed for when the indexer is a boolean array
and the number of true values equals the length of ``value``. In
this case, no exception is raised.
Parameters
----------
indexer : sequence
The key for the setitem
... | [
"Validate",
"that",
"value",
"and",
"indexer",
"are",
"the",
"same",
"length",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2511-L2552 | train |
pandas-dev/pandas | pandas/core/indexing.py | convert_missing_indexer | def convert_missing_indexer(indexer):
"""
reverse convert a missing indexer, which is a dict
return the scalar indexer and a boolean indicating if we converted
"""
if isinstance(indexer, dict):
# a missing key (but not a tuple indexer)
indexer = indexer['key']
if isinstanc... | python | def convert_missing_indexer(indexer):
"""
reverse convert a missing indexer, which is a dict
return the scalar indexer and a boolean indicating if we converted
"""
if isinstance(indexer, dict):
# a missing key (but not a tuple indexer)
indexer = indexer['key']
if isinstanc... | [
"def",
"convert_missing_indexer",
"(",
"indexer",
")",
":",
"if",
"isinstance",
"(",
"indexer",
",",
"dict",
")",
":",
"# a missing key (but not a tuple indexer)",
"indexer",
"=",
"indexer",
"[",
"'key'",
"]",
"if",
"isinstance",
"(",
"indexer",
",",
"bool",
")"... | reverse convert a missing indexer, which is a dict
return the scalar indexer and a boolean indicating if we converted | [
"reverse",
"convert",
"a",
"missing",
"indexer",
"which",
"is",
"a",
"dict",
"return",
"the",
"scalar",
"indexer",
"and",
"a",
"boolean",
"indicating",
"if",
"we",
"converted"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2555-L2570 | train |
pandas-dev/pandas | pandas/core/indexing.py | convert_from_missing_indexer_tuple | def convert_from_missing_indexer_tuple(indexer, axes):
"""
create a filtered indexer that doesn't have any missing indexers
"""
def get_indexer(_i, _idx):
return (axes[_i].get_loc(_idx['key']) if isinstance(_idx, dict) else
_idx)
return tuple(get_indexer(_i, _idx) for _i, _... | python | def convert_from_missing_indexer_tuple(indexer, axes):
"""
create a filtered indexer that doesn't have any missing indexers
"""
def get_indexer(_i, _idx):
return (axes[_i].get_loc(_idx['key']) if isinstance(_idx, dict) else
_idx)
return tuple(get_indexer(_i, _idx) for _i, _... | [
"def",
"convert_from_missing_indexer_tuple",
"(",
"indexer",
",",
"axes",
")",
":",
"def",
"get_indexer",
"(",
"_i",
",",
"_idx",
")",
":",
"return",
"(",
"axes",
"[",
"_i",
"]",
".",
"get_loc",
"(",
"_idx",
"[",
"'key'",
"]",
")",
"if",
"isinstance",
... | create a filtered indexer that doesn't have any missing indexers | [
"create",
"a",
"filtered",
"indexer",
"that",
"doesn",
"t",
"have",
"any",
"missing",
"indexers"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2573-L2582 | train |
pandas-dev/pandas | pandas/core/indexing.py | maybe_convert_indices | def maybe_convert_indices(indices, n):
"""
Attempt to convert indices into valid, positive indices.
If we have negative indices, translate to positive here.
If we have indices that are out-of-bounds, raise an IndexError.
Parameters
----------
indices : array-like
The array of indic... | python | def maybe_convert_indices(indices, n):
"""
Attempt to convert indices into valid, positive indices.
If we have negative indices, translate to positive here.
If we have indices that are out-of-bounds, raise an IndexError.
Parameters
----------
indices : array-like
The array of indic... | [
"def",
"maybe_convert_indices",
"(",
"indices",
",",
"n",
")",
":",
"if",
"isinstance",
"(",
"indices",
",",
"list",
")",
":",
"indices",
"=",
"np",
".",
"array",
"(",
"indices",
")",
"if",
"len",
"(",
"indices",
")",
"==",
"0",
":",
"# If list is empt... | Attempt to convert indices into valid, positive indices.
If we have negative indices, translate to positive here.
If we have indices that are out-of-bounds, raise an IndexError.
Parameters
----------
indices : array-like
The array of indices that we are to convert.
n : int
The ... | [
"Attempt",
"to",
"convert",
"indices",
"into",
"valid",
"positive",
"indices",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2585-L2626 | train |
pandas-dev/pandas | pandas/core/indexing.py | validate_indices | def validate_indices(indices, n):
"""
Perform bounds-checking for an indexer.
-1 is allowed for indicating missing values.
Parameters
----------
indices : ndarray
n : int
length of the array being indexed
Raises
------
ValueError
Examples
--------
>>> vali... | python | def validate_indices(indices, n):
"""
Perform bounds-checking for an indexer.
-1 is allowed for indicating missing values.
Parameters
----------
indices : ndarray
n : int
length of the array being indexed
Raises
------
ValueError
Examples
--------
>>> vali... | [
"def",
"validate_indices",
"(",
"indices",
",",
"n",
")",
":",
"if",
"len",
"(",
"indices",
")",
":",
"min_idx",
"=",
"indices",
".",
"min",
"(",
")",
"if",
"min_idx",
"<",
"-",
"1",
":",
"msg",
"=",
"(",
"\"'indices' contains values less than allowed ({} ... | Perform bounds-checking for an indexer.
-1 is allowed for indicating missing values.
Parameters
----------
indices : ndarray
n : int
length of the array being indexed
Raises
------
ValueError
Examples
--------
>>> validate_indices([1, 2], 3)
# OK
>>> valid... | [
"Perform",
"bounds",
"-",
"checking",
"for",
"an",
"indexer",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2629-L2667 | train |
pandas-dev/pandas | pandas/core/indexing.py | maybe_convert_ix | def maybe_convert_ix(*args):
"""
We likely want to take the cross-product
"""
ixify = True
for arg in args:
if not isinstance(arg, (np.ndarray, list, ABCSeries, Index)):
ixify = False
if ixify:
return np.ix_(*args)
else:
return args | python | def maybe_convert_ix(*args):
"""
We likely want to take the cross-product
"""
ixify = True
for arg in args:
if not isinstance(arg, (np.ndarray, list, ABCSeries, Index)):
ixify = False
if ixify:
return np.ix_(*args)
else:
return args | [
"def",
"maybe_convert_ix",
"(",
"*",
"args",
")",
":",
"ixify",
"=",
"True",
"for",
"arg",
"in",
"args",
":",
"if",
"not",
"isinstance",
"(",
"arg",
",",
"(",
"np",
".",
"ndarray",
",",
"list",
",",
"ABCSeries",
",",
"Index",
")",
")",
":",
"ixify"... | We likely want to take the cross-product | [
"We",
"likely",
"want",
"to",
"take",
"the",
"cross",
"-",
"product"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2670-L2683 | train |
pandas-dev/pandas | pandas/core/indexing.py | _non_reducing_slice | def _non_reducing_slice(slice_):
"""
Ensurse that a slice doesn't reduce to a Series or Scalar.
Any user-paseed `subset` should have this called on it
to make sure we're always working with DataFrames.
"""
# default to column slice, like DataFrame
# ['A', 'B'] -> IndexSlices[:, ['A', 'B']]
... | python | def _non_reducing_slice(slice_):
"""
Ensurse that a slice doesn't reduce to a Series or Scalar.
Any user-paseed `subset` should have this called on it
to make sure we're always working with DataFrames.
"""
# default to column slice, like DataFrame
# ['A', 'B'] -> IndexSlices[:, ['A', 'B']]
... | [
"def",
"_non_reducing_slice",
"(",
"slice_",
")",
":",
"# default to column slice, like DataFrame",
"# ['A', 'B'] -> IndexSlices[:, ['A', 'B']]",
"kinds",
"=",
"(",
"ABCSeries",
",",
"np",
".",
"ndarray",
",",
"Index",
",",
"list",
",",
"str",
")",
"if",
"isinstance",... | Ensurse that a slice doesn't reduce to a Series or Scalar.
Any user-paseed `subset` should have this called on it
to make sure we're always working with DataFrames. | [
"Ensurse",
"that",
"a",
"slice",
"doesn",
"t",
"reduce",
"to",
"a",
"Series",
"or",
"Scalar",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2734-L2762 | train |
pandas-dev/pandas | pandas/core/indexing.py | _maybe_numeric_slice | def _maybe_numeric_slice(df, slice_, include_bool=False):
"""
want nice defaults for background_gradient that don't break
with non-numeric data. But if slice_ is passed go with that.
"""
if slice_ is None:
dtypes = [np.number]
if include_bool:
dtypes.append(bool)
... | python | def _maybe_numeric_slice(df, slice_, include_bool=False):
"""
want nice defaults for background_gradient that don't break
with non-numeric data. But if slice_ is passed go with that.
"""
if slice_ is None:
dtypes = [np.number]
if include_bool:
dtypes.append(bool)
... | [
"def",
"_maybe_numeric_slice",
"(",
"df",
",",
"slice_",
",",
"include_bool",
"=",
"False",
")",
":",
"if",
"slice_",
"is",
"None",
":",
"dtypes",
"=",
"[",
"np",
".",
"number",
"]",
"if",
"include_bool",
":",
"dtypes",
".",
"append",
"(",
"bool",
")",... | want nice defaults for background_gradient that don't break
with non-numeric data. But if slice_ is passed go with that. | [
"want",
"nice",
"defaults",
"for",
"background_gradient",
"that",
"don",
"t",
"break",
"with",
"non",
"-",
"numeric",
"data",
".",
"But",
"if",
"slice_",
"is",
"passed",
"go",
"with",
"that",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2765-L2775 | train |
pandas-dev/pandas | pandas/core/indexing.py | _NDFrameIndexer._has_valid_tuple | def _has_valid_tuple(self, key):
""" check the key for valid keys across my indexer """
for i, k in enumerate(key):
if i >= self.obj.ndim:
raise IndexingError('Too many indexers')
try:
self._validate_key(k, i)
except ValueError:
... | python | def _has_valid_tuple(self, key):
""" check the key for valid keys across my indexer """
for i, k in enumerate(key):
if i >= self.obj.ndim:
raise IndexingError('Too many indexers')
try:
self._validate_key(k, i)
except ValueError:
... | [
"def",
"_has_valid_tuple",
"(",
"self",
",",
"key",
")",
":",
"for",
"i",
",",
"k",
"in",
"enumerate",
"(",
"key",
")",
":",
"if",
"i",
">=",
"self",
".",
"obj",
".",
"ndim",
":",
"raise",
"IndexingError",
"(",
"'Too many indexers'",
")",
"try",
":",... | check the key for valid keys across my indexer | [
"check",
"the",
"key",
"for",
"valid",
"keys",
"across",
"my",
"indexer"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L215-L225 | train |
pandas-dev/pandas | pandas/core/indexing.py | _NDFrameIndexer._has_valid_positional_setitem_indexer | def _has_valid_positional_setitem_indexer(self, indexer):
""" validate that an positional indexer cannot enlarge its target
will raise if needed, does not modify the indexer externally
"""
if isinstance(indexer, dict):
raise IndexError("{0} cannot enlarge its target object"
... | python | def _has_valid_positional_setitem_indexer(self, indexer):
""" validate that an positional indexer cannot enlarge its target
will raise if needed, does not modify the indexer externally
"""
if isinstance(indexer, dict):
raise IndexError("{0} cannot enlarge its target object"
... | [
"def",
"_has_valid_positional_setitem_indexer",
"(",
"self",
",",
"indexer",
")",
":",
"if",
"isinstance",
"(",
"indexer",
",",
"dict",
")",
":",
"raise",
"IndexError",
"(",
"\"{0} cannot enlarge its target object\"",
".",
"format",
"(",
"self",
".",
"name",
")",
... | validate that an positional indexer cannot enlarge its target
will raise if needed, does not modify the indexer externally | [
"validate",
"that",
"an",
"positional",
"indexer",
"cannot",
"enlarge",
"its",
"target",
"will",
"raise",
"if",
"needed",
"does",
"not",
"modify",
"the",
"indexer",
"externally"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L270-L295 | train |
pandas-dev/pandas | pandas/core/indexing.py | _NDFrameIndexer._align_series | def _align_series(self, indexer, ser, multiindex_indexer=False):
"""
Parameters
----------
indexer : tuple, slice, scalar
The indexer used to get the locations that will be set to
`ser`
ser : pd.Series
The values to assign to the locations spe... | python | def _align_series(self, indexer, ser, multiindex_indexer=False):
"""
Parameters
----------
indexer : tuple, slice, scalar
The indexer used to get the locations that will be set to
`ser`
ser : pd.Series
The values to assign to the locations spe... | [
"def",
"_align_series",
"(",
"self",
",",
"indexer",
",",
"ser",
",",
"multiindex_indexer",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"indexer",
",",
"(",
"slice",
",",
"np",
".",
"ndarray",
",",
"list",
",",
"Index",
")",
")",
":",
"indexer",
... | Parameters
----------
indexer : tuple, slice, scalar
The indexer used to get the locations that will be set to
`ser`
ser : pd.Series
The values to assign to the locations specified by `indexer`
multiindex_indexer : boolean, optional
Defau... | [
"Parameters",
"----------",
"indexer",
":",
"tuple",
"slice",
"scalar",
"The",
"indexer",
"used",
"to",
"get",
"the",
"locations",
"that",
"will",
"be",
"set",
"to",
"ser"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L657-L781 | train |
pandas-dev/pandas | pandas/core/indexing.py | _NDFrameIndexer._multi_take_opportunity | def _multi_take_opportunity(self, tup):
"""
Check whether there is the possibility to use ``_multi_take``.
Currently the limit is that all axes being indexed must be indexed with
list-likes.
Parameters
----------
tup : tuple
Tuple of indexers, one per... | python | def _multi_take_opportunity(self, tup):
"""
Check whether there is the possibility to use ``_multi_take``.
Currently the limit is that all axes being indexed must be indexed with
list-likes.
Parameters
----------
tup : tuple
Tuple of indexers, one per... | [
"def",
"_multi_take_opportunity",
"(",
"self",
",",
"tup",
")",
":",
"if",
"not",
"all",
"(",
"is_list_like_indexer",
"(",
"x",
")",
"for",
"x",
"in",
"tup",
")",
":",
"return",
"False",
"# just too complicated",
"if",
"any",
"(",
"com",
".",
"is_bool_inde... | Check whether there is the possibility to use ``_multi_take``.
Currently the limit is that all axes being indexed must be indexed with
list-likes.
Parameters
----------
tup : tuple
Tuple of indexers, one per axis
Returns
-------
boolean: Whet... | [
"Check",
"whether",
"there",
"is",
"the",
"possibility",
"to",
"use",
"_multi_take",
".",
"Currently",
"the",
"limit",
"is",
"that",
"all",
"axes",
"being",
"indexed",
"must",
"be",
"indexed",
"with",
"list",
"-",
"likes",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L890-L912 | train |
pandas-dev/pandas | pandas/core/indexing.py | _NDFrameIndexer._multi_take | def _multi_take(self, tup):
"""
Create the indexers for the passed tuple of keys, and execute the take
operation. This allows the take operation to be executed all at once -
rather than once for each dimension - improving efficiency.
Parameters
----------
tup : t... | python | def _multi_take(self, tup):
"""
Create the indexers for the passed tuple of keys, and execute the take
operation. This allows the take operation to be executed all at once -
rather than once for each dimension - improving efficiency.
Parameters
----------
tup : t... | [
"def",
"_multi_take",
"(",
"self",
",",
"tup",
")",
":",
"# GH 836",
"o",
"=",
"self",
".",
"obj",
"d",
"=",
"{",
"axis",
":",
"self",
".",
"_get_listlike_indexer",
"(",
"key",
",",
"axis",
")",
"for",
"(",
"key",
",",
"axis",
")",
"in",
"zip",
"... | Create the indexers for the passed tuple of keys, and execute the take
operation. This allows the take operation to be executed all at once -
rather than once for each dimension - improving efficiency.
Parameters
----------
tup : tuple
Tuple of indexers, one per axis... | [
"Create",
"the",
"indexers",
"for",
"the",
"passed",
"tuple",
"of",
"keys",
"and",
"execute",
"the",
"take",
"operation",
".",
"This",
"allows",
"the",
"take",
"operation",
"to",
"be",
"executed",
"all",
"at",
"once",
"-",
"rather",
"than",
"once",
"for",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L914-L933 | train |
pandas-dev/pandas | pandas/core/indexing.py | _NDFrameIndexer._get_listlike_indexer | def _get_listlike_indexer(self, key, axis, raise_missing=False):
"""
Transform a list-like of keys into a new index and an indexer.
Parameters
----------
key : list-like
Target labels
axis: int
Dimension on which the indexing is being made
... | python | def _get_listlike_indexer(self, key, axis, raise_missing=False):
"""
Transform a list-like of keys into a new index and an indexer.
Parameters
----------
key : list-like
Target labels
axis: int
Dimension on which the indexing is being made
... | [
"def",
"_get_listlike_indexer",
"(",
"self",
",",
"key",
",",
"axis",
",",
"raise_missing",
"=",
"False",
")",
":",
"o",
"=",
"self",
".",
"obj",
"ax",
"=",
"o",
".",
"_get_axis",
"(",
"axis",
")",
"# Have the index compute an indexer or return None",
"# if it... | Transform a list-like of keys into a new index and an indexer.
Parameters
----------
key : list-like
Target labels
axis: int
Dimension on which the indexing is being made
raise_missing: bool
Whether to raise a KeyError if some labels are not f... | [
"Transform",
"a",
"list",
"-",
"like",
"of",
"keys",
"into",
"a",
"new",
"index",
"and",
"an",
"indexer",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1112-L1166 | train |
pandas-dev/pandas | pandas/core/indexing.py | _NDFrameIndexer._getitem_iterable | def _getitem_iterable(self, key, axis=None):
"""
Index current object with an an iterable key (which can be a boolean
indexer, or a collection of keys).
Parameters
----------
key : iterable
Target labels, or boolean indexer
axis: int, default None
... | python | def _getitem_iterable(self, key, axis=None):
"""
Index current object with an an iterable key (which can be a boolean
indexer, or a collection of keys).
Parameters
----------
key : iterable
Target labels, or boolean indexer
axis: int, default None
... | [
"def",
"_getitem_iterable",
"(",
"self",
",",
"key",
",",
"axis",
"=",
"None",
")",
":",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"self",
".",
"axis",
"or",
"0",
"self",
".",
"_validate_key",
"(",
"key",
",",
"axis",
")",
"labels",
"=",
"self"... | Index current object with an an iterable key (which can be a boolean
indexer, or a collection of keys).
Parameters
----------
key : iterable
Target labels, or boolean indexer
axis: int, default None
Dimension on which the indexing is being made
R... | [
"Index",
"current",
"object",
"with",
"an",
"an",
"iterable",
"key",
"(",
"which",
"can",
"be",
"a",
"boolean",
"indexer",
"or",
"a",
"collection",
"of",
"keys",
")",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1168-L1211 | train |
pandas-dev/pandas | pandas/core/indexing.py | _NDFrameIndexer._validate_read_indexer | def _validate_read_indexer(self, key, indexer, axis, raise_missing=False):
"""
Check that indexer can be used to return a result (e.g. at least one
element was found, unless the list of keys was actually empty).
Parameters
----------
key : list-like
Target la... | python | def _validate_read_indexer(self, key, indexer, axis, raise_missing=False):
"""
Check that indexer can be used to return a result (e.g. at least one
element was found, unless the list of keys was actually empty).
Parameters
----------
key : list-like
Target la... | [
"def",
"_validate_read_indexer",
"(",
"self",
",",
"key",
",",
"indexer",
",",
"axis",
",",
"raise_missing",
"=",
"False",
")",
":",
"ax",
"=",
"self",
".",
"obj",
".",
"_get_axis",
"(",
"axis",
")",
"if",
"len",
"(",
"key",
")",
"==",
"0",
":",
"r... | Check that indexer can be used to return a result (e.g. at least one
element was found, unless the list of keys was actually empty).
Parameters
----------
key : list-like
Target labels (only used to show correct error message)
indexer: array-like of booleans
... | [
"Check",
"that",
"indexer",
"can",
"be",
"used",
"to",
"return",
"a",
"result",
"(",
"e",
".",
"g",
".",
"at",
"least",
"one",
"element",
"was",
"found",
"unless",
"the",
"list",
"of",
"keys",
"was",
"actually",
"empty",
")",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1213-L1273 | train |
pandas-dev/pandas | pandas/core/indexing.py | _NDFrameIndexer._convert_to_indexer | def _convert_to_indexer(self, obj, axis=None, is_setter=False,
raise_missing=False):
"""
Convert indexing key into something we can use to do actual fancy
indexing on an ndarray
Examples
ix[:5] -> slice(0, 5)
ix[[1,2,3]] -> [1,2,3]
ix[... | python | def _convert_to_indexer(self, obj, axis=None, is_setter=False,
raise_missing=False):
"""
Convert indexing key into something we can use to do actual fancy
indexing on an ndarray
Examples
ix[:5] -> slice(0, 5)
ix[[1,2,3]] -> [1,2,3]
ix[... | [
"def",
"_convert_to_indexer",
"(",
"self",
",",
"obj",
",",
"axis",
"=",
"None",
",",
"is_setter",
"=",
"False",
",",
"raise_missing",
"=",
"False",
")",
":",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"self",
".",
"axis",
"or",
"0",
"labels",
"="... | Convert indexing key into something we can use to do actual fancy
indexing on an ndarray
Examples
ix[:5] -> slice(0, 5)
ix[[1,2,3]] -> [1,2,3]
ix[['foo', 'bar', 'baz']] -> [i, j, k] (indices of foo, bar, baz)
Going by Zen of Python?
'In the face of ambiguity, re... | [
"Convert",
"indexing",
"key",
"into",
"something",
"we",
"can",
"use",
"to",
"do",
"actual",
"fancy",
"indexing",
"on",
"an",
"ndarray"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1275-L1366 | train |
pandas-dev/pandas | pandas/core/indexing.py | _IXIndexer._convert_for_reindex | def _convert_for_reindex(self, key, axis=None):
"""
Transform a list of keys into a new array ready to be used as axis of
the object we return (e.g. including NaNs).
Parameters
----------
key : list-like
Target labels
axis: int
Where the i... | python | def _convert_for_reindex(self, key, axis=None):
"""
Transform a list of keys into a new array ready to be used as axis of
the object we return (e.g. including NaNs).
Parameters
----------
key : list-like
Target labels
axis: int
Where the i... | [
"def",
"_convert_for_reindex",
"(",
"self",
",",
"key",
",",
"axis",
"=",
"None",
")",
":",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"self",
".",
"axis",
"or",
"0",
"labels",
"=",
"self",
".",
"obj",
".",
"_get_axis",
"(",
"axis",
")",
"if",
... | Transform a list of keys into a new array ready to be used as axis of
the object we return (e.g. including NaNs).
Parameters
----------
key : list-like
Target labels
axis: int
Where the indexing is being made
Returns
-------
list-... | [
"Transform",
"a",
"list",
"of",
"keys",
"into",
"a",
"new",
"array",
"ready",
"to",
"be",
"used",
"as",
"axis",
"of",
"the",
"object",
"we",
"return",
"(",
"e",
".",
"g",
".",
"including",
"NaNs",
")",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1442-L1483 | train |
pandas-dev/pandas | pandas/core/indexing.py | _LocationIndexer._get_slice_axis | def _get_slice_axis(self, slice_obj, axis=None):
""" this is pretty simple as we just have to deal with labels """
if axis is None:
axis = self.axis or 0
obj = self.obj
if not need_slice(slice_obj):
return obj.copy(deep=False)
labels = obj._get_axis(axis... | python | def _get_slice_axis(self, slice_obj, axis=None):
""" this is pretty simple as we just have to deal with labels """
if axis is None:
axis = self.axis or 0
obj = self.obj
if not need_slice(slice_obj):
return obj.copy(deep=False)
labels = obj._get_axis(axis... | [
"def",
"_get_slice_axis",
"(",
"self",
",",
"slice_obj",
",",
"axis",
"=",
"None",
")",
":",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"self",
".",
"axis",
"or",
"0",
"obj",
"=",
"self",
".",
"obj",
"if",
"not",
"need_slice",
"(",
"slice_obj",
... | this is pretty simple as we just have to deal with labels | [
"this",
"is",
"pretty",
"simple",
"as",
"we",
"just",
"have",
"to",
"deal",
"with",
"labels"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1526-L1542 | train |
pandas-dev/pandas | pandas/core/indexing.py | _LocIndexer._get_partial_string_timestamp_match_key | def _get_partial_string_timestamp_match_key(self, key, labels):
"""Translate any partial string timestamp matches in key, returning the
new key (GH 10331)"""
if isinstance(labels, MultiIndex):
if (isinstance(key, str) and labels.levels[0].is_all_dates):
# Convert key ... | python | def _get_partial_string_timestamp_match_key(self, key, labels):
"""Translate any partial string timestamp matches in key, returning the
new key (GH 10331)"""
if isinstance(labels, MultiIndex):
if (isinstance(key, str) and labels.levels[0].is_all_dates):
# Convert key ... | [
"def",
"_get_partial_string_timestamp_match_key",
"(",
"self",
",",
"key",
",",
"labels",
")",
":",
"if",
"isinstance",
"(",
"labels",
",",
"MultiIndex",
")",
":",
"if",
"(",
"isinstance",
"(",
"key",
",",
"str",
")",
"and",
"labels",
".",
"levels",
"[",
... | Translate any partial string timestamp matches in key, returning the
new key (GH 10331) | [
"Translate",
"any",
"partial",
"string",
"timestamp",
"matches",
"in",
"key",
"returning",
"the",
"new",
"key",
"(",
"GH",
"10331",
")"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1835-L1856 | train |
pandas-dev/pandas | pandas/core/indexing.py | _iLocIndexer._validate_integer | def _validate_integer(self, key, axis):
"""
Check that 'key' is a valid position in the desired axis.
Parameters
----------
key : int
Requested position
axis : int
Desired axis
Returns
-------
None
Raises
... | python | def _validate_integer(self, key, axis):
"""
Check that 'key' is a valid position in the desired axis.
Parameters
----------
key : int
Requested position
axis : int
Desired axis
Returns
-------
None
Raises
... | [
"def",
"_validate_integer",
"(",
"self",
",",
"key",
",",
"axis",
")",
":",
"len_axis",
"=",
"len",
"(",
"self",
".",
"obj",
".",
"_get_axis",
"(",
"axis",
")",
")",
"if",
"key",
">=",
"len_axis",
"or",
"key",
"<",
"-",
"len_axis",
":",
"raise",
"I... | Check that 'key' is a valid position in the desired axis.
Parameters
----------
key : int
Requested position
axis : int
Desired axis
Returns
-------
None
Raises
------
IndexError
If 'key' is not a vali... | [
"Check",
"that",
"key",
"is",
"a",
"valid",
"position",
"in",
"the",
"desired",
"axis",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2125-L2148 | train |
pandas-dev/pandas | pandas/core/indexing.py | _iLocIndexer._get_list_axis | def _get_list_axis(self, key, axis=None):
"""
Return Series values by list or array of integers
Parameters
----------
key : list-like positional indexer
axis : int (can only be zero)
Returns
-------
Series object
"""
if axis is No... | python | def _get_list_axis(self, key, axis=None):
"""
Return Series values by list or array of integers
Parameters
----------
key : list-like positional indexer
axis : int (can only be zero)
Returns
-------
Series object
"""
if axis is No... | [
"def",
"_get_list_axis",
"(",
"self",
",",
"key",
",",
"axis",
"=",
"None",
")",
":",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"self",
".",
"axis",
"or",
"0",
"try",
":",
"return",
"self",
".",
"obj",
".",
"_take",
"(",
"key",
",",
"axis",
... | Return Series values by list or array of integers
Parameters
----------
key : list-like positional indexer
axis : int (can only be zero)
Returns
-------
Series object | [
"Return",
"Series",
"values",
"by",
"list",
"or",
"array",
"of",
"integers"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2193-L2212 | train |
pandas-dev/pandas | pandas/core/indexing.py | _iLocIndexer._convert_to_indexer | def _convert_to_indexer(self, obj, axis=None, is_setter=False):
""" much simpler as we only have to deal with our valid types """
if axis is None:
axis = self.axis or 0
# make need to convert a float key
if isinstance(obj, slice):
return self._convert_slice_index... | python | def _convert_to_indexer(self, obj, axis=None, is_setter=False):
""" much simpler as we only have to deal with our valid types """
if axis is None:
axis = self.axis or 0
# make need to convert a float key
if isinstance(obj, slice):
return self._convert_slice_index... | [
"def",
"_convert_to_indexer",
"(",
"self",
",",
"obj",
",",
"axis",
"=",
"None",
",",
"is_setter",
"=",
"False",
")",
":",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"self",
".",
"axis",
"or",
"0",
"# make need to convert a float key",
"if",
"isinstance... | much simpler as we only have to deal with our valid types | [
"much",
"simpler",
"as",
"we",
"only",
"have",
"to",
"deal",
"with",
"our",
"valid",
"types"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2244-L2261 | train |
pandas-dev/pandas | pandas/core/indexing.py | _AtIndexer._convert_key | def _convert_key(self, key, is_setter=False):
""" require they keys to be the same type as the index (so we don't
fallback)
"""
# allow arbitrary setting
if is_setter:
return list(key)
for ax, i in zip(self.obj.axes, key):
if ax.is_integer():
... | python | def _convert_key(self, key, is_setter=False):
""" require they keys to be the same type as the index (so we don't
fallback)
"""
# allow arbitrary setting
if is_setter:
return list(key)
for ax, i in zip(self.obj.axes, key):
if ax.is_integer():
... | [
"def",
"_convert_key",
"(",
"self",
",",
"key",
",",
"is_setter",
"=",
"False",
")",
":",
"# allow arbitrary setting",
"if",
"is_setter",
":",
"return",
"list",
"(",
"key",
")",
"for",
"ax",
",",
"i",
"in",
"zip",
"(",
"self",
".",
"obj",
".",
"axes",
... | require they keys to be the same type as the index (so we don't
fallback) | [
"require",
"they",
"keys",
"to",
"be",
"the",
"same",
"type",
"as",
"the",
"index",
"(",
"so",
"we",
"don",
"t",
"fallback",
")"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2349-L2368 | train |
pandas-dev/pandas | pandas/core/indexing.py | _iAtIndexer._convert_key | def _convert_key(self, key, is_setter=False):
""" require integer args (and convert to label arguments) """
for a, i in zip(self.obj.axes, key):
if not is_integer(i):
raise ValueError("iAt based indexing can only have integer "
"indexers")
... | python | def _convert_key(self, key, is_setter=False):
""" require integer args (and convert to label arguments) """
for a, i in zip(self.obj.axes, key):
if not is_integer(i):
raise ValueError("iAt based indexing can only have integer "
"indexers")
... | [
"def",
"_convert_key",
"(",
"self",
",",
"key",
",",
"is_setter",
"=",
"False",
")",
":",
"for",
"a",
",",
"i",
"in",
"zip",
"(",
"self",
".",
"obj",
".",
"axes",
",",
"key",
")",
":",
"if",
"not",
"is_integer",
"(",
"i",
")",
":",
"raise",
"Va... | require integer args (and convert to label arguments) | [
"require",
"integer",
"args",
"(",
"and",
"convert",
"to",
"label",
"arguments",
")"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2422-L2428 | train |
pandas-dev/pandas | pandas/core/sparse/frame.py | to_manager | def to_manager(sdf, columns, index):
""" create and return the block manager from a dataframe of series,
columns, index
"""
# from BlockManager perspective
axes = [ensure_index(columns), ensure_index(index)]
return create_block_manager_from_arrays(
[sdf[c] for c in columns], columns, a... | python | def to_manager(sdf, columns, index):
""" create and return the block manager from a dataframe of series,
columns, index
"""
# from BlockManager perspective
axes = [ensure_index(columns), ensure_index(index)]
return create_block_manager_from_arrays(
[sdf[c] for c in columns], columns, a... | [
"def",
"to_manager",
"(",
"sdf",
",",
"columns",
",",
"index",
")",
":",
"# from BlockManager perspective",
"axes",
"=",
"[",
"ensure_index",
"(",
"columns",
")",
",",
"ensure_index",
"(",
"index",
")",
"]",
"return",
"create_block_manager_from_arrays",
"(",
"["... | create and return the block manager from a dataframe of series,
columns, index | [
"create",
"and",
"return",
"the",
"block",
"manager",
"from",
"a",
"dataframe",
"of",
"series",
"columns",
"index"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L951-L960 | train |
pandas-dev/pandas | pandas/core/sparse/frame.py | stack_sparse_frame | def stack_sparse_frame(frame):
"""
Only makes sense when fill_value is NaN
"""
lengths = [s.sp_index.npoints for _, s in frame.items()]
nobs = sum(lengths)
# this is pretty fast
minor_codes = np.repeat(np.arange(len(frame.columns)), lengths)
inds_to_concat = []
vals_to_concat = []
... | python | def stack_sparse_frame(frame):
"""
Only makes sense when fill_value is NaN
"""
lengths = [s.sp_index.npoints for _, s in frame.items()]
nobs = sum(lengths)
# this is pretty fast
minor_codes = np.repeat(np.arange(len(frame.columns)), lengths)
inds_to_concat = []
vals_to_concat = []
... | [
"def",
"stack_sparse_frame",
"(",
"frame",
")",
":",
"lengths",
"=",
"[",
"s",
".",
"sp_index",
".",
"npoints",
"for",
"_",
",",
"s",
"in",
"frame",
".",
"items",
"(",
")",
"]",
"nobs",
"=",
"sum",
"(",
"lengths",
")",
"# this is pretty fast",
"minor_c... | Only makes sense when fill_value is NaN | [
"Only",
"makes",
"sense",
"when",
"fill_value",
"is",
"NaN"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L963-L994 | train |
pandas-dev/pandas | pandas/core/sparse/frame.py | homogenize | def homogenize(series_dict):
"""
Conform a set of SparseSeries (with NaN fill_value) to a common SparseIndex
corresponding to the locations where they all have data
Parameters
----------
series_dict : dict or DataFrame
Notes
-----
Using the dumbest algorithm I could think of. Shoul... | python | def homogenize(series_dict):
"""
Conform a set of SparseSeries (with NaN fill_value) to a common SparseIndex
corresponding to the locations where they all have data
Parameters
----------
series_dict : dict or DataFrame
Notes
-----
Using the dumbest algorithm I could think of. Shoul... | [
"def",
"homogenize",
"(",
"series_dict",
")",
":",
"index",
"=",
"None",
"need_reindex",
"=",
"False",
"for",
"_",
",",
"series",
"in",
"series_dict",
".",
"items",
"(",
")",
":",
"if",
"not",
"np",
".",
"isnan",
"(",
"series",
".",
"fill_value",
")",
... | Conform a set of SparseSeries (with NaN fill_value) to a common SparseIndex
corresponding to the locations where they all have data
Parameters
----------
series_dict : dict or DataFrame
Notes
-----
Using the dumbest algorithm I could think of. Should put some more thought
into this
... | [
"Conform",
"a",
"set",
"of",
"SparseSeries",
"(",
"with",
"NaN",
"fill_value",
")",
"to",
"a",
"common",
"SparseIndex",
"corresponding",
"to",
"the",
"locations",
"where",
"they",
"all",
"have",
"data"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L997-L1039 | train |
pandas-dev/pandas | pandas/core/sparse/frame.py | SparseDataFrame._init_matrix | def _init_matrix(self, data, index, columns, dtype=None):
"""
Init self from ndarray or list of lists.
"""
data = prep_ndarray(data, copy=False)
index, columns = self._prep_index(data, index, columns)
data = {idx: data[:, i] for i, idx in enumerate(columns)}
retur... | python | def _init_matrix(self, data, index, columns, dtype=None):
"""
Init self from ndarray or list of lists.
"""
data = prep_ndarray(data, copy=False)
index, columns = self._prep_index(data, index, columns)
data = {idx: data[:, i] for i, idx in enumerate(columns)}
retur... | [
"def",
"_init_matrix",
"(",
"self",
",",
"data",
",",
"index",
",",
"columns",
",",
"dtype",
"=",
"None",
")",
":",
"data",
"=",
"prep_ndarray",
"(",
"data",
",",
"copy",
"=",
"False",
")",
"index",
",",
"columns",
"=",
"self",
".",
"_prep_index",
"(... | Init self from ndarray or list of lists. | [
"Init",
"self",
"from",
"ndarray",
"or",
"list",
"of",
"lists",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L190-L197 | train |
pandas-dev/pandas | pandas/core/sparse/frame.py | SparseDataFrame._init_spmatrix | def _init_spmatrix(self, data, index, columns, dtype=None,
fill_value=None):
"""
Init self from scipy.sparse matrix.
"""
index, columns = self._prep_index(data, index, columns)
data = data.tocoo()
N = len(index)
# Construct a dict of Sparse... | python | def _init_spmatrix(self, data, index, columns, dtype=None,
fill_value=None):
"""
Init self from scipy.sparse matrix.
"""
index, columns = self._prep_index(data, index, columns)
data = data.tocoo()
N = len(index)
# Construct a dict of Sparse... | [
"def",
"_init_spmatrix",
"(",
"self",
",",
"data",
",",
"index",
",",
"columns",
",",
"dtype",
"=",
"None",
",",
"fill_value",
"=",
"None",
")",
":",
"index",
",",
"columns",
"=",
"self",
".",
"_prep_index",
"(",
"data",
",",
"index",
",",
"columns",
... | Init self from scipy.sparse matrix. | [
"Init",
"self",
"from",
"scipy",
".",
"sparse",
"matrix",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L199-L229 | train |
pandas-dev/pandas | pandas/core/sparse/frame.py | SparseDataFrame.to_coo | def to_coo(self):
"""
Return the contents of the frame as a sparse SciPy COO matrix.
.. versionadded:: 0.20.0
Returns
-------
coo_matrix : scipy.sparse.spmatrix
If the caller is heterogeneous and contains booleans or objects,
the result will be o... | python | def to_coo(self):
"""
Return the contents of the frame as a sparse SciPy COO matrix.
.. versionadded:: 0.20.0
Returns
-------
coo_matrix : scipy.sparse.spmatrix
If the caller is heterogeneous and contains booleans or objects,
the result will be o... | [
"def",
"to_coo",
"(",
"self",
")",
":",
"try",
":",
"from",
"scipy",
".",
"sparse",
"import",
"coo_matrix",
"except",
"ImportError",
":",
"raise",
"ImportError",
"(",
"'Scipy is not installed'",
")",
"dtype",
"=",
"find_common_type",
"(",
"self",
".",
"dtypes"... | Return the contents of the frame as a sparse SciPy COO matrix.
.. versionadded:: 0.20.0
Returns
-------
coo_matrix : scipy.sparse.spmatrix
If the caller is heterogeneous and contains booleans or objects,
the result will be of dtype=object. See Notes.
No... | [
"Return",
"the",
"contents",
"of",
"the",
"frame",
"as",
"a",
"sparse",
"SciPy",
"COO",
"matrix",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L246-L288 | train |
pandas-dev/pandas | pandas/core/sparse/frame.py | SparseDataFrame._unpickle_sparse_frame_compat | def _unpickle_sparse_frame_compat(self, state):
"""
Original pickle format
"""
series, cols, idx, fv, kind = state
if not isinstance(cols, Index): # pragma: no cover
from pandas.io.pickle import _unpickle_array
columns = _unpickle_array(cols)
els... | python | def _unpickle_sparse_frame_compat(self, state):
"""
Original pickle format
"""
series, cols, idx, fv, kind = state
if not isinstance(cols, Index): # pragma: no cover
from pandas.io.pickle import _unpickle_array
columns = _unpickle_array(cols)
els... | [
"def",
"_unpickle_sparse_frame_compat",
"(",
"self",
",",
"state",
")",
":",
"series",
",",
"cols",
",",
"idx",
",",
"fv",
",",
"kind",
"=",
"state",
"if",
"not",
"isinstance",
"(",
"cols",
",",
"Index",
")",
":",
"# pragma: no cover",
"from",
"pandas",
... | Original pickle format | [
"Original",
"pickle",
"format"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L302-L327 | train |
pandas-dev/pandas | pandas/core/sparse/frame.py | SparseDataFrame.to_dense | def to_dense(self):
"""
Convert to dense DataFrame
Returns
-------
df : DataFrame
"""
data = {k: v.to_dense() for k, v in self.items()}
return DataFrame(data, index=self.index, columns=self.columns) | python | def to_dense(self):
"""
Convert to dense DataFrame
Returns
-------
df : DataFrame
"""
data = {k: v.to_dense() for k, v in self.items()}
return DataFrame(data, index=self.index, columns=self.columns) | [
"def",
"to_dense",
"(",
"self",
")",
":",
"data",
"=",
"{",
"k",
":",
"v",
".",
"to_dense",
"(",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
"}",
"return",
"DataFrame",
"(",
"data",
",",
"index",
"=",
"self",
".",
"index",
... | Convert to dense DataFrame
Returns
-------
df : DataFrame | [
"Convert",
"to",
"dense",
"DataFrame"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L329-L338 | train |
pandas-dev/pandas | pandas/core/sparse/frame.py | SparseDataFrame._apply_columns | def _apply_columns(self, func):
"""
Get new SparseDataFrame applying func to each columns
"""
new_data = {col: func(series)
for col, series in self.items()}
return self._constructor(
data=new_data, index=self.index, columns=self.columns,
... | python | def _apply_columns(self, func):
"""
Get new SparseDataFrame applying func to each columns
"""
new_data = {col: func(series)
for col, series in self.items()}
return self._constructor(
data=new_data, index=self.index, columns=self.columns,
... | [
"def",
"_apply_columns",
"(",
"self",
",",
"func",
")",
":",
"new_data",
"=",
"{",
"col",
":",
"func",
"(",
"series",
")",
"for",
"col",
",",
"series",
"in",
"self",
".",
"items",
"(",
")",
"}",
"return",
"self",
".",
"_constructor",
"(",
"data",
"... | Get new SparseDataFrame applying func to each columns | [
"Get",
"new",
"SparseDataFrame",
"applying",
"func",
"to",
"each",
"columns"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L340-L350 | train |
pandas-dev/pandas | pandas/core/sparse/frame.py | SparseDataFrame.copy | def copy(self, deep=True):
"""
Make a copy of this SparseDataFrame
"""
result = super().copy(deep=deep)
result._default_fill_value = self._default_fill_value
result._default_kind = self._default_kind
return result | python | def copy(self, deep=True):
"""
Make a copy of this SparseDataFrame
"""
result = super().copy(deep=deep)
result._default_fill_value = self._default_fill_value
result._default_kind = self._default_kind
return result | [
"def",
"copy",
"(",
"self",
",",
"deep",
"=",
"True",
")",
":",
"result",
"=",
"super",
"(",
")",
".",
"copy",
"(",
"deep",
"=",
"deep",
")",
"result",
".",
"_default_fill_value",
"=",
"self",
".",
"_default_fill_value",
"result",
".",
"_default_kind",
... | Make a copy of this SparseDataFrame | [
"Make",
"a",
"copy",
"of",
"this",
"SparseDataFrame"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L355-L362 | train |
pandas-dev/pandas | pandas/core/sparse/frame.py | SparseDataFrame.density | def density(self):
"""
Ratio of non-sparse points to total (dense) data points
represented in the frame
"""
tot_nonsparse = sum(ser.sp_index.npoints
for _, ser in self.items())
tot = len(self.index) * len(self.columns)
return tot_nonspa... | python | def density(self):
"""
Ratio of non-sparse points to total (dense) data points
represented in the frame
"""
tot_nonsparse = sum(ser.sp_index.npoints
for _, ser in self.items())
tot = len(self.index) * len(self.columns)
return tot_nonspa... | [
"def",
"density",
"(",
"self",
")",
":",
"tot_nonsparse",
"=",
"sum",
"(",
"ser",
".",
"sp_index",
".",
"npoints",
"for",
"_",
",",
"ser",
"in",
"self",
".",
"items",
"(",
")",
")",
"tot",
"=",
"len",
"(",
"self",
".",
"index",
")",
"*",
"len",
... | Ratio of non-sparse points to total (dense) data points
represented in the frame | [
"Ratio",
"of",
"non",
"-",
"sparse",
"points",
"to",
"total",
"(",
"dense",
")",
"data",
"points",
"represented",
"in",
"the",
"frame"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L373-L381 | train |
pandas-dev/pandas | pandas/core/sparse/frame.py | SparseDataFrame._sanitize_column | def _sanitize_column(self, key, value, **kwargs):
"""
Creates a new SparseArray from the input value.
Parameters
----------
key : object
value : scalar, Series, or array-like
kwargs : dict
Returns
-------
sanitized_column : SparseArray
... | python | def _sanitize_column(self, key, value, **kwargs):
"""
Creates a new SparseArray from the input value.
Parameters
----------
key : object
value : scalar, Series, or array-like
kwargs : dict
Returns
-------
sanitized_column : SparseArray
... | [
"def",
"_sanitize_column",
"(",
"self",
",",
"key",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"sp_maker",
"(",
"x",
",",
"index",
"=",
"None",
")",
":",
"return",
"SparseArray",
"(",
"x",
",",
"index",
"=",
"index",
",",
"fill_value",
... | Creates a new SparseArray from the input value.
Parameters
----------
key : object
value : scalar, Series, or array-like
kwargs : dict
Returns
-------
sanitized_column : SparseArray | [
"Creates",
"a",
"new",
"SparseArray",
"from",
"the",
"input",
"value",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L403-L448 | train |
pandas-dev/pandas | pandas/core/sparse/frame.py | SparseDataFrame.xs | def xs(self, key, axis=0, copy=False):
"""
Returns a row (cross-section) from the SparseDataFrame as a Series
object.
Parameters
----------
key : some index contained in the index
Returns
-------
xs : Series
"""
if axis == 1:
... | python | def xs(self, key, axis=0, copy=False):
"""
Returns a row (cross-section) from the SparseDataFrame as a Series
object.
Parameters
----------
key : some index contained in the index
Returns
-------
xs : Series
"""
if axis == 1:
... | [
"def",
"xs",
"(",
"self",
",",
"key",
",",
"axis",
"=",
"0",
",",
"copy",
"=",
"False",
")",
":",
"if",
"axis",
"==",
"1",
":",
"data",
"=",
"self",
"[",
"key",
"]",
"return",
"data",
"i",
"=",
"self",
".",
"index",
".",
"get_loc",
"(",
"key"... | Returns a row (cross-section) from the SparseDataFrame as a Series
object.
Parameters
----------
key : some index contained in the index
Returns
-------
xs : Series | [
"Returns",
"a",
"row",
"(",
"cross",
"-",
"section",
")",
"from",
"the",
"SparseDataFrame",
"as",
"a",
"Series",
"object",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L531-L550 | train |
pandas-dev/pandas | pandas/core/sparse/frame.py | SparseDataFrame.transpose | def transpose(self, *args, **kwargs):
"""
Returns a DataFrame with the rows/columns switched.
"""
nv.validate_transpose(args, kwargs)
return self._constructor(
self.values.T, index=self.columns, columns=self.index,
default_fill_value=self._default_fill_val... | python | def transpose(self, *args, **kwargs):
"""
Returns a DataFrame with the rows/columns switched.
"""
nv.validate_transpose(args, kwargs)
return self._constructor(
self.values.T, index=self.columns, columns=self.index,
default_fill_value=self._default_fill_val... | [
"def",
"transpose",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"nv",
".",
"validate_transpose",
"(",
"args",
",",
"kwargs",
")",
"return",
"self",
".",
"_constructor",
"(",
"self",
".",
"values",
".",
"T",
",",
"index",
"=",
... | Returns a DataFrame with the rows/columns switched. | [
"Returns",
"a",
"DataFrame",
"with",
"the",
"rows",
"/",
"columns",
"switched",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L809-L817 | train |
pandas-dev/pandas | pandas/core/sparse/frame.py | SparseDataFrame.cumsum | def cumsum(self, axis=0, *args, **kwargs):
"""
Return SparseDataFrame of cumulative sums over requested axis.
Parameters
----------
axis : {0, 1}
0 for row-wise, 1 for column-wise
Returns
-------
y : SparseDataFrame
"""
nv.val... | python | def cumsum(self, axis=0, *args, **kwargs):
"""
Return SparseDataFrame of cumulative sums over requested axis.
Parameters
----------
axis : {0, 1}
0 for row-wise, 1 for column-wise
Returns
-------
y : SparseDataFrame
"""
nv.val... | [
"def",
"cumsum",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"nv",
".",
"validate_cumsum",
"(",
"args",
",",
"kwargs",
")",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"self",
".",
"_stat_axis_number",... | Return SparseDataFrame of cumulative sums over requested axis.
Parameters
----------
axis : {0, 1}
0 for row-wise, 1 for column-wise
Returns
-------
y : SparseDataFrame | [
"Return",
"SparseDataFrame",
"of",
"cumulative",
"sums",
"over",
"requested",
"axis",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L828-L846 | train |
pandas-dev/pandas | pandas/core/sparse/frame.py | SparseDataFrame.apply | def apply(self, func, axis=0, broadcast=None, reduce=None,
result_type=None):
"""
Analogous to DataFrame.apply, for SparseDataFrame
Parameters
----------
func : function
Function to apply to each column
axis : {0, 1, 'index', 'columns'}
... | python | def apply(self, func, axis=0, broadcast=None, reduce=None,
result_type=None):
"""
Analogous to DataFrame.apply, for SparseDataFrame
Parameters
----------
func : function
Function to apply to each column
axis : {0, 1, 'index', 'columns'}
... | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"axis",
"=",
"0",
",",
"broadcast",
"=",
"None",
",",
"reduce",
"=",
"None",
",",
"result_type",
"=",
"None",
")",
":",
"if",
"not",
"len",
"(",
"self",
".",
"columns",
")",
":",
"return",
"self",
"a... | Analogous to DataFrame.apply, for SparseDataFrame
Parameters
----------
func : function
Function to apply to each column
axis : {0, 1, 'index', 'columns'}
broadcast : bool, default False
For aggregation functions, return object of same size with values
... | [
"Analogous",
"to",
"DataFrame",
".",
"apply",
"for",
"SparseDataFrame"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L858-L931 | train |
pandas-dev/pandas | scripts/generate_pip_deps_from_conda.py | conda_package_to_pip | def conda_package_to_pip(package):
"""
Convert a conda package to its pip equivalent.
In most cases they are the same, those are the exceptions:
- Packages that should be excluded (in `EXCLUDE`)
- Packages that should be renamed (in `RENAME`)
- A package requiring a specific version, in conda i... | python | def conda_package_to_pip(package):
"""
Convert a conda package to its pip equivalent.
In most cases they are the same, those are the exceptions:
- Packages that should be excluded (in `EXCLUDE`)
- Packages that should be renamed (in `RENAME`)
- A package requiring a specific version, in conda i... | [
"def",
"conda_package_to_pip",
"(",
"package",
")",
":",
"if",
"package",
"in",
"EXCLUDE",
":",
"return",
"package",
"=",
"re",
".",
"sub",
"(",
"'(?<=[^<>])='",
",",
"'=='",
",",
"package",
")",
".",
"strip",
"(",
")",
"for",
"compare",
"in",
"(",
"'<... | Convert a conda package to its pip equivalent.
In most cases they are the same, those are the exceptions:
- Packages that should be excluded (in `EXCLUDE`)
- Packages that should be renamed (in `RENAME`)
- A package requiring a specific version, in conda is defined with a single
equal (e.g. ``pan... | [
"Convert",
"a",
"conda",
"package",
"to",
"its",
"pip",
"equivalent",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/generate_pip_deps_from_conda.py#L26-L51 | train |
pandas-dev/pandas | scripts/generate_pip_deps_from_conda.py | main | def main(conda_fname, pip_fname, compare=False):
"""
Generate the pip dependencies file from the conda file, or compare that
they are synchronized (``compare=True``).
Parameters
----------
conda_fname : str
Path to the conda file with dependencies (e.g. `environment.yml`).
pip_fname... | python | def main(conda_fname, pip_fname, compare=False):
"""
Generate the pip dependencies file from the conda file, or compare that
they are synchronized (``compare=True``).
Parameters
----------
conda_fname : str
Path to the conda file with dependencies (e.g. `environment.yml`).
pip_fname... | [
"def",
"main",
"(",
"conda_fname",
",",
"pip_fname",
",",
"compare",
"=",
"False",
")",
":",
"with",
"open",
"(",
"conda_fname",
")",
"as",
"conda_fd",
":",
"deps",
"=",
"yaml",
".",
"safe_load",
"(",
"conda_fd",
")",
"[",
"'dependencies'",
"]",
"pip_dep... | Generate the pip dependencies file from the conda file, or compare that
they are synchronized (``compare=True``).
Parameters
----------
conda_fname : str
Path to the conda file with dependencies (e.g. `environment.yml`).
pip_fname : str
Path to the pip file with dependencies (e.g. `... | [
"Generate",
"the",
"pip",
"dependencies",
"file",
"from",
"the",
"conda",
"file",
"or",
"compare",
"that",
"they",
"are",
"synchronized",
"(",
"compare",
"=",
"True",
")",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/generate_pip_deps_from_conda.py#L54-L97 | train |
pandas-dev/pandas | pandas/core/dtypes/cast.py | maybe_convert_platform | def maybe_convert_platform(values):
""" try to do platform conversion, allow ndarray or list here """
if isinstance(values, (list, tuple)):
values = construct_1d_object_array_from_listlike(list(values))
if getattr(values, 'dtype', None) == np.object_:
if hasattr(values, '_values'):
... | python | def maybe_convert_platform(values):
""" try to do platform conversion, allow ndarray or list here """
if isinstance(values, (list, tuple)):
values = construct_1d_object_array_from_listlike(list(values))
if getattr(values, 'dtype', None) == np.object_:
if hasattr(values, '_values'):
... | [
"def",
"maybe_convert_platform",
"(",
"values",
")",
":",
"if",
"isinstance",
"(",
"values",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"values",
"=",
"construct_1d_object_array_from_listlike",
"(",
"list",
"(",
"values",
")",
")",
"if",
"getattr",
"(",
... | try to do platform conversion, allow ndarray or list here | [
"try",
"to",
"do",
"platform",
"conversion",
"allow",
"ndarray",
"or",
"list",
"here"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L35-L45 | train |
pandas-dev/pandas | pandas/core/dtypes/cast.py | is_nested_object | def is_nested_object(obj):
"""
return a boolean if we have a nested object, e.g. a Series with 1 or
more Series elements
This may not be necessarily be performant.
"""
if isinstance(obj, ABCSeries) and is_object_dtype(obj):
if any(isinstance(v, ABCSeries) for v in obj.values):
... | python | def is_nested_object(obj):
"""
return a boolean if we have a nested object, e.g. a Series with 1 or
more Series elements
This may not be necessarily be performant.
"""
if isinstance(obj, ABCSeries) and is_object_dtype(obj):
if any(isinstance(v, ABCSeries) for v in obj.values):
... | [
"def",
"is_nested_object",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"ABCSeries",
")",
"and",
"is_object_dtype",
"(",
"obj",
")",
":",
"if",
"any",
"(",
"isinstance",
"(",
"v",
",",
"ABCSeries",
")",
"for",
"v",
"in",
"obj",
".",
"va... | return a boolean if we have a nested object, e.g. a Series with 1 or
more Series elements
This may not be necessarily be performant. | [
"return",
"a",
"boolean",
"if",
"we",
"have",
"a",
"nested",
"object",
"e",
".",
"g",
".",
"a",
"Series",
"with",
"1",
"or",
"more",
"Series",
"elements"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L48-L62 | train |
pandas-dev/pandas | pandas/core/dtypes/cast.py | maybe_downcast_to_dtype | def maybe_downcast_to_dtype(result, dtype):
""" try to cast to the specified dtype (e.g. convert back to bool/int
or could be an astype of float64->float32
"""
if is_scalar(result):
return result
def trans(x):
return x
if isinstance(dtype, str):
if dtype == 'infer':
... | python | def maybe_downcast_to_dtype(result, dtype):
""" try to cast to the specified dtype (e.g. convert back to bool/int
or could be an astype of float64->float32
"""
if is_scalar(result):
return result
def trans(x):
return x
if isinstance(dtype, str):
if dtype == 'infer':
... | [
"def",
"maybe_downcast_to_dtype",
"(",
"result",
",",
"dtype",
")",
":",
"if",
"is_scalar",
"(",
"result",
")",
":",
"return",
"result",
"def",
"trans",
"(",
"x",
")",
":",
"return",
"x",
"if",
"isinstance",
"(",
"dtype",
",",
"str",
")",
":",
"if",
... | try to cast to the specified dtype (e.g. convert back to bool/int
or could be an astype of float64->float32 | [
"try",
"to",
"cast",
"to",
"the",
"specified",
"dtype",
"(",
"e",
".",
"g",
".",
"convert",
"back",
"to",
"bool",
"/",
"int",
"or",
"could",
"be",
"an",
"astype",
"of",
"float64",
"-",
">",
"float32"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L65-L167 | train |
pandas-dev/pandas | pandas/core/dtypes/cast.py | maybe_upcast_putmask | def maybe_upcast_putmask(result, mask, other):
"""
A safe version of putmask that potentially upcasts the result.
The result is replaced with the first N elements of other,
where N is the number of True values in mask.
If the length of other is shorter than N, other will be repeated.
Parameters... | python | def maybe_upcast_putmask(result, mask, other):
"""
A safe version of putmask that potentially upcasts the result.
The result is replaced with the first N elements of other,
where N is the number of True values in mask.
If the length of other is shorter than N, other will be repeated.
Parameters... | [
"def",
"maybe_upcast_putmask",
"(",
"result",
",",
"mask",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"result",
",",
"np",
".",
"ndarray",
")",
":",
"raise",
"ValueError",
"(",
"\"The result input must be a ndarray.\"",
")",
"if",
"mask",
".",
"... | A safe version of putmask that potentially upcasts the result.
The result is replaced with the first N elements of other,
where N is the number of True values in mask.
If the length of other is shorter than N, other will be repeated.
Parameters
----------
result : ndarray
The destinatio... | [
"A",
"safe",
"version",
"of",
"putmask",
"that",
"potentially",
"upcasts",
"the",
"result",
".",
"The",
"result",
"is",
"replaced",
"with",
"the",
"first",
"N",
"elements",
"of",
"other",
"where",
"N",
"is",
"the",
"number",
"of",
"True",
"values",
"in",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L170-L265 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.