partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | DataFrame.diff | 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... | pandas/core/frame.py | 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):
"""
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
----------
... | [
"First",
"discrete",
"difference",
"of",
"element",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L6145-L6234 | [
"def",
"diff",
"(",
"self",
",",
"periods",
"=",
"1",
",",
"axis",
"=",
"0",
")",
":",
"bm_axis",
"=",
"self",
".",
"_get_block_manager_axis",
"(",
"axis",
")",
"new_data",
"=",
"self",
".",
"_data",
".",
"diff",
"(",
"n",
"=",
"periods",
",",
"axi... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame._gotitem | 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 | pandas/core/frame.py | 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,
) -> Union[Series, ABCDataFrame]:
"""
Sub-classes to define. Return a sliced object.
Parameters
----------
... | [
"Sub",
"-",
"classes",
"to",
"define",
".",
"Return",
"a",
"sliced",
"object",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L6239-L6261 | [
"def",
"_gotitem",
"(",
"self",
",",
"key",
":",
"Union",
"[",
"str",
",",
"List",
"[",
"str",
"]",
"]",
",",
"ndim",
":",
"int",
",",
"subset",
":",
"Optional",
"[",
"Union",
"[",
"Series",
",",
"ABCDataFrame",
"]",
"]",
"=",
"None",
",",
")",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame.apply | 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 ... | pandas/core/frame.py | 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 ... | [
"Apply",
"a",
"function",
"along",
"an",
"axis",
"of",
"the",
"DataFrame",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L6355-L6534 | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"axis",
"=",
"0",
",",
"broadcast",
"=",
"None",
",",
"raw",
"=",
"False",
",",
"reduce",
"=",
"None",
",",
"result_type",
"=",
"None",
",",
"args",
"=",
"(",
")",
",",
"*",
"*",
"kwds",
")",
":",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame.applymap | 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
... | pandas/core/frame.py | 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):
"""
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... | [
"Apply",
"a",
"function",
"to",
"a",
"Dataframe",
"elementwise",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L6536-L6600 | [
"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... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame.append | 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... | pandas/core/frame.py | 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):
"""
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 : ... | [
"Append",
"rows",
"of",
"other",
"to",
"the",
"end",
"of",
"caller",
"returning",
"a",
"new",
"object",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L6605-L6739 | [
"def",
"append",
"(",
"self",
",",
"other",
",",
"ignore_index",
"=",
"False",
",",
"verify_integrity",
"=",
"False",
",",
"sort",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"(",
"Series",
",",
"dict",
")",
")",
":",
"if",
"isinsta... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame.join | 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... | pandas/core/frame.py | 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):
"""
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... | [
"Join",
"columns",
"of",
"another",
"DataFrame",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L6741-L6862 | [
"def",
"join",
"(",
"self",
",",
"other",
",",
"on",
"=",
"None",
",",
"how",
"=",
"'left'",
",",
"lsuffix",
"=",
"''",
",",
"rsuffix",
"=",
"''",
",",
"sort",
"=",
"False",
")",
":",
"# For SparseDataFrame's benefit",
"return",
"self",
".",
"_join_com... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame.round | 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 ... | pandas/core/frame.py | 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):
"""
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... | [
"Round",
"a",
"DataFrame",
"to",
"a",
"variable",
"number",
"of",
"decimal",
"places",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L6917-L7028 | [
"def",
"round",
"(",
"self",
",",
"decimals",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"pandas",
".",
"core",
".",
"reshape",
".",
"concat",
"import",
"concat",
"def",
"_dict_round",
"(",
"df",
",",
"decimals",
")",
":... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame.corr | 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... | pandas/core/frame.py | 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):
"""
Compute pairwise correlation of columns, excluding NA/null values.
Parameters
----------
method : {'pearson', 'kendall', 'spearman'} or callable
* pearson : standard correlation coefficient
* kendall : ... | [
"Compute",
"pairwise",
"correlation",
"of",
"columns",
"excluding",
"NA",
"/",
"null",
"values",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7033-L7115 | [
"def",
"corr",
"(",
"self",
",",
"method",
"=",
"'pearson'",
",",
"min_periods",
"=",
"1",
")",
":",
"numeric_df",
"=",
"self",
".",
"_get_numeric_data",
"(",
")",
"cols",
"=",
"numeric_df",
".",
"columns",
"idx",
"=",
"cols",
".",
"copy",
"(",
")",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame.cov | 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... | pandas/core/frame.py | 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):
"""
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... | [
"Compute",
"pairwise",
"covariance",
"of",
"columns",
"excluding",
"NA",
"/",
"null",
"values",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7117-L7226 | [
"def",
"cov",
"(",
"self",
",",
"min_periods",
"=",
"None",
")",
":",
"numeric_df",
"=",
"self",
".",
"_get_numeric_data",
"(",
")",
"cols",
"=",
"numeric_df",
".",
"columns",
"idx",
"=",
"cols",
".",
"copy",
"(",
")",
"mat",
"=",
"numeric_df",
".",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame.corrwith | 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... | pandas/core/frame.py | 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'):
"""
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
... | [
"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",
... | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7228-L7314 | [
"def",
"corrwith",
"(",
"self",
",",
"other",
",",
"axis",
"=",
"0",
",",
"drop",
"=",
"False",
",",
"method",
"=",
"'pearson'",
")",
":",
"axis",
"=",
"self",
".",
"_get_axis_number",
"(",
"axis",
")",
"this",
"=",
"self",
".",
"_get_numeric_data",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame.count | 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... | pandas/core/frame.py | 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):
"""
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 :... | [
"Count",
"non",
"-",
"NA",
"cells",
"for",
"each",
"column",
"or",
"row",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7319-L7419 | [
"def",
"count",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"level",
"=",
"None",
",",
"numeric_only",
"=",
"False",
")",
":",
"axis",
"=",
"self",
".",
"_get_axis_number",
"(",
"axis",
")",
"if",
"level",
"is",
"not",
"None",
":",
"return",
"self",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame.nunique | 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... | pandas/core/frame.py | 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):
"""
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'},... | [
"Count",
"distinct",
"observations",
"over",
"requested",
"axis",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7565-L7605 | [
"def",
"nunique",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"dropna",
"=",
"True",
")",
":",
"return",
"self",
".",
"apply",
"(",
"Series",
".",
"nunique",
",",
"axis",
"=",
"axis",
",",
"dropna",
"=",
"dropna",
")"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame.idxmin | 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... | pandas/core/frame.py | 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):
"""
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... | [
"Return",
"index",
"of",
"first",
"occurrence",
"of",
"minimum",
"over",
"requested",
"axis",
".",
"NA",
"/",
"null",
"values",
"are",
"excluded",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7607-L7642 | [
"def",
"idxmin",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"skipna",
"=",
"True",
")",
":",
"axis",
"=",
"self",
".",
"_get_axis_number",
"(",
"axis",
")",
"indices",
"=",
"nanops",
".",
"nanargmin",
"(",
"self",
".",
"values",
",",
"axis",
"=",
"ax... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame._get_agg_axis | Let's be explicit about this. | pandas/core/frame.py | 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):
"""
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) | [
"Let",
"s",
"be",
"explicit",
"about",
"this",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7681-L7690 | [
"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... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame.mode | 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 ... | pandas/core/frame.py | 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):
"""
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... | [
"Get",
"the",
"mode",
"(",
"s",
")",
"of",
"each",
"element",
"along",
"the",
"selected",
"axis",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7692-L7776 | [
"def",
"mode",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"numeric_only",
"=",
"False",
",",
"dropna",
"=",
"True",
")",
":",
"data",
"=",
"self",
"if",
"not",
"numeric_only",
"else",
"self",
".",
"_get_numeric_data",
"(",
")",
"def",
"f",
"(",
"s",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame.quantile | 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... | pandas/core/frame.py | 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'):
"""
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... | [
"Return",
"values",
"at",
"the",
"given",
"quantile",
"over",
"requested",
"axis",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7778-L7869 | [
"def",
"quantile",
"(",
"self",
",",
"q",
"=",
"0.5",
",",
"axis",
"=",
"0",
",",
"numeric_only",
"=",
"True",
",",
"interpolation",
"=",
"'linear'",
")",
":",
"self",
".",
"_check_percentile",
"(",
"q",
")",
"data",
"=",
"self",
".",
"_get_numeric_dat... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame.to_timestamp | 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... | pandas/core/frame.py | 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):
"""
Cast to DatetimeIndex of timestamps, at *beginning* of period.
Parameters
----------
freq : str, default frequency of PeriodIndex
Desired frequency.
how : {'s', 'e', 'start', 'end'}
... | [
"Cast",
"to",
"DatetimeIndex",
"of",
"timestamps",
"at",
"*",
"beginning",
"*",
"of",
"period",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7871-L7904 | [
"def",
"to_timestamp",
"(",
"self",
",",
"freq",
"=",
"None",
",",
"how",
"=",
"'start'",
",",
"axis",
"=",
"0",
",",
"copy",
"=",
"True",
")",
":",
"new_data",
"=",
"self",
".",
"_data",
"if",
"copy",
":",
"new_data",
"=",
"new_data",
".",
"copy",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | DataFrame.isin | 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... | pandas/core/frame.py | 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):
"""
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'... | [
"Whether",
"each",
"element",
"in",
"the",
"DataFrame",
"is",
"contained",
"in",
"values",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7939-L8026 | [
"def",
"isin",
"(",
"self",
",",
"values",
")",
":",
"if",
"isinstance",
"(",
"values",
",",
"dict",
")",
":",
"from",
"pandas",
".",
"core",
".",
"reshape",
".",
"concat",
"import",
"concat",
"values",
"=",
"collections",
".",
"defaultdict",
"(",
"lis... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | integer_array | 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 | pandas/core/arrays/integer.py | 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):
"""
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
------
... | [
"Infer",
"and",
"return",
"an",
"integer",
"array",
"of",
"the",
"values",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L92-L112 | [
"def",
"integer_array",
"(",
"values",
",",
"dtype",
"=",
"None",
",",
"copy",
"=",
"False",
")",
":",
"values",
",",
"mask",
"=",
"coerce_to_array",
"(",
"values",
",",
"dtype",
"=",
"dtype",
",",
"copy",
"=",
"copy",
")",
"return",
"IntegerArray",
"(... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | safe_cast | Safely cast the values to the dtype if they
are equivalent, meaning floats must be equivalent to the
ints. | pandas/core/arrays/integer.py | 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):
"""
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)
... | [
"Safely",
"cast",
"the",
"values",
"to",
"the",
"dtype",
"if",
"they",
"are",
"equivalent",
"meaning",
"floats",
"must",
"be",
"equivalent",
"to",
"the",
"ints",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L115-L132 | [
"def",
"safe_cast",
"(",
"values",
",",
"dtype",
",",
"copy",
")",
":",
"try",
":",
"return",
"values",
".",
"astype",
"(",
"dtype",
",",
"casting",
"=",
"'safe'",
",",
"copy",
"=",
"copy",
")",
"except",
"TypeError",
":",
"casted",
"=",
"values",
".... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | coerce_to_array | 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) | pandas/core/arrays/integer.py | 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):
"""
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
... | [
"Coerce",
"the",
"input",
"values",
"array",
"to",
"numpy",
"arrays",
"with",
"a",
"mask"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L135-L221 | [
"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'",
")",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _IntegerDtype.construct_from_string | Construction from a string, raise a TypeError if not
possible | pandas/core/arrays/integer.py | 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):
"""
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)) | [
"Construction",
"from",
"a",
"string",
"raise",
"a",
"TypeError",
"if",
"not",
"possible"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L81-L89 | [
"def",
"construct_from_string",
"(",
"cls",
",",
"string",
")",
":",
"if",
"string",
"==",
"cls",
".",
"name",
":",
"return",
"cls",
"(",
")",
"raise",
"TypeError",
"(",
"\"Cannot construct a '{}' from \"",
"\"'{}'\"",
".",
"format",
"(",
"cls",
",",
"string... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | IntegerArray._coerce_to_ndarray | coerce to an ndarary of object dtype | pandas/core/arrays/integer.py | 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):
"""
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 | [
"coerce",
"to",
"an",
"ndarary",
"of",
"object",
"dtype"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L328-L336 | [
"def",
"_coerce_to_ndarray",
"(",
"self",
")",
":",
"# TODO(jreback) make this better",
"data",
"=",
"self",
".",
"_data",
".",
"astype",
"(",
"object",
")",
"data",
"[",
"self",
".",
"_mask",
"]",
"=",
"self",
".",
"_na_value",
"return",
"data"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | IntegerArray.astype | 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... | pandas/core/arrays/integer.py | 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):
"""
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... | [
"Cast",
"to",
"a",
"NumPy",
"array",
"or",
"IntegerArray",
"with",
"dtype",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L420-L452 | [
"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... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | IntegerArray.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... | pandas/core/arrays/integer.py | 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):
"""
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
... | [
"Returns",
"a",
"Series",
"containing",
"counts",
"of",
"each",
"category",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L465-L509 | [
"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",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | IntegerArray._values_for_argsort | Return values for sorting.
Returns
-------
ndarray
The transformed values should maintain the ordering between values
within the array.
See Also
--------
ExtensionArray.argsort | pandas/core/arrays/integer.py | 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:
"""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",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L511-L526 | [
"def",
"_values_for_argsort",
"(",
"self",
")",
"->",
"np",
".",
"ndarray",
":",
"data",
"=",
"self",
".",
"_data",
".",
"copy",
"(",
")",
"data",
"[",
"self",
".",
"_mask",
"]",
"=",
"data",
".",
"min",
"(",
")",
"-",
"1",
"return",
"data"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | IntegerArray._maybe_mask_result | Parameters
----------
result : array-like
mask : array-like bool
other : scalar or array-like
op_name : str | pandas/core/arrays/integer.py | 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):
"""
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... | [
"Parameters",
"----------",
"result",
":",
"array",
"-",
"like",
"mask",
":",
"array",
"-",
"like",
"bool",
"other",
":",
"scalar",
"or",
"array",
"-",
"like",
"op_name",
":",
"str"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L593-L616 | [
"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",
".",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | length_of_indexer | return the length of a single non-tuple indexer which could be a slice | pandas/core/indexing.py | 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):
"""
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
... | [
"return",
"the",
"length",
"of",
"a",
"single",
"non",
"-",
"tuple",
"indexer",
"which",
"could",
"be",
"a",
"slice"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2431-L2457 | [
"def",
"length_of_indexer",
"(",
"indexer",
",",
"target",
"=",
"None",
")",
":",
"if",
"target",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"indexer",
",",
"slice",
")",
":",
"target_len",
"=",
"len",
"(",
"target",
")",
"start",
"=",
"indexer",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | convert_to_index_sliceable | if we are index sliceable, then return my slicer, otherwise return None | pandas/core/indexing.py | 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):
"""
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
... | [
"if",
"we",
"are",
"index",
"sliceable",
"then",
"return",
"my",
"slicer",
"otherwise",
"return",
"None"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2460-L2482 | [
"def",
"convert_to_index_sliceable",
"(",
"obj",
",",
"key",
")",
":",
"idx",
"=",
"obj",
".",
"index",
"if",
"isinstance",
"(",
"key",
",",
"slice",
")",
":",
"return",
"idx",
".",
"_convert_slice_indexer",
"(",
"key",
",",
"kind",
"=",
"'getitem'",
")"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | check_setitem_lengths | 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
... | pandas/core/indexing.py | 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):
"""
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
----... | [
"Validate",
"that",
"value",
"and",
"indexer",
"are",
"the",
"same",
"length",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2511-L2552 | [
"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"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | convert_missing_indexer | reverse convert a missing indexer, which is a dict
return the scalar indexer and a boolean indicating if we converted | pandas/core/indexing.py | 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):
"""
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... | [
"reverse",
"convert",
"a",
"missing",
"indexer",
"which",
"is",
"a",
"dict",
"return",
"the",
"scalar",
"indexer",
"and",
"a",
"boolean",
"indicating",
"if",
"we",
"converted"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2555-L2570 | [
"def",
"convert_missing_indexer",
"(",
"indexer",
")",
":",
"if",
"isinstance",
"(",
"indexer",
",",
"dict",
")",
":",
"# a missing key (but not a tuple indexer)",
"indexer",
"=",
"indexer",
"[",
"'key'",
"]",
"if",
"isinstance",
"(",
"indexer",
",",
"bool",
")"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | convert_from_missing_indexer_tuple | create a filtered indexer that doesn't have any missing indexers | pandas/core/indexing.py | 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):
"""
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, _... | [
"create",
"a",
"filtered",
"indexer",
"that",
"doesn",
"t",
"have",
"any",
"missing",
"indexers"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2573-L2582 | [
"def",
"convert_from_missing_indexer_tuple",
"(",
"indexer",
",",
"axes",
")",
":",
"def",
"get_indexer",
"(",
"_i",
",",
"_idx",
")",
":",
"return",
"(",
"axes",
"[",
"_i",
"]",
".",
"get_loc",
"(",
"_idx",
"[",
"'key'",
"]",
")",
"if",
"isinstance",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | maybe_convert_indices | 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 ... | pandas/core/indexing.py | 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):
"""
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... | [
"Attempt",
"to",
"convert",
"indices",
"into",
"valid",
"positive",
"indices",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2585-L2626 | [
"def",
"maybe_convert_indices",
"(",
"indices",
",",
"n",
")",
":",
"if",
"isinstance",
"(",
"indices",
",",
"list",
")",
":",
"indices",
"=",
"np",
".",
"array",
"(",
"indices",
")",
"if",
"len",
"(",
"indices",
")",
"==",
"0",
":",
"# If list is empt... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | validate_indices | 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... | pandas/core/indexing.py | 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):
"""
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... | [
"Perform",
"bounds",
"-",
"checking",
"for",
"an",
"indexer",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2629-L2667 | [
"def",
"validate_indices",
"(",
"indices",
",",
"n",
")",
":",
"if",
"len",
"(",
"indices",
")",
":",
"min_idx",
"=",
"indices",
".",
"min",
"(",
")",
"if",
"min_idx",
"<",
"-",
"1",
":",
"msg",
"=",
"(",
"\"'indices' contains values less than allowed ({} ... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | maybe_convert_ix | We likely want to take the cross-product | pandas/core/indexing.py | 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):
"""
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 | [
"We",
"likely",
"want",
"to",
"take",
"the",
"cross",
"-",
"product"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2670-L2683 | [
"def",
"maybe_convert_ix",
"(",
"*",
"args",
")",
":",
"ixify",
"=",
"True",
"for",
"arg",
"in",
"args",
":",
"if",
"not",
"isinstance",
"(",
"arg",
",",
"(",
"np",
".",
"ndarray",
",",
"list",
",",
"ABCSeries",
",",
"Index",
")",
")",
":",
"ixify"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _non_reducing_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. | pandas/core/indexing.py | 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_):
"""
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']]
... | [
"Ensurse",
"that",
"a",
"slice",
"doesn",
"t",
"reduce",
"to",
"a",
"Series",
"or",
"Scalar",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2734-L2762 | [
"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",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _maybe_numeric_slice | want nice defaults for background_gradient that don't break
with non-numeric data. But if slice_ is passed go with that. | pandas/core/indexing.py | 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):
"""
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)
... | [
"want",
"nice",
"defaults",
"for",
"background_gradient",
"that",
"don",
"t",
"break",
"with",
"non",
"-",
"numeric",
"data",
".",
"But",
"if",
"slice_",
"is",
"passed",
"go",
"with",
"that",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2765-L2775 | [
"def",
"_maybe_numeric_slice",
"(",
"df",
",",
"slice_",
",",
"include_bool",
"=",
"False",
")",
":",
"if",
"slice_",
"is",
"None",
":",
"dtypes",
"=",
"[",
"np",
".",
"number",
"]",
"if",
"include_bool",
":",
"dtypes",
".",
"append",
"(",
"bool",
")",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _NDFrameIndexer._has_valid_tuple | check the key for valid keys across my indexer | pandas/core/indexing.py | 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):
""" 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:
... | [
"check",
"the",
"key",
"for",
"valid",
"keys",
"across",
"my",
"indexer"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L215-L225 | [
"def",
"_has_valid_tuple",
"(",
"self",
",",
"key",
")",
":",
"for",
"i",
",",
"k",
"in",
"enumerate",
"(",
"key",
")",
":",
"if",
"i",
">=",
"self",
".",
"obj",
".",
"ndim",
":",
"raise",
"IndexingError",
"(",
"'Too many indexers'",
")",
"try",
":",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _NDFrameIndexer._has_valid_positional_setitem_indexer | validate that an positional indexer cannot enlarge its target
will raise if needed, does not modify the indexer externally | pandas/core/indexing.py | 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):
""" 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"
... | [
"validate",
"that",
"an",
"positional",
"indexer",
"cannot",
"enlarge",
"its",
"target",
"will",
"raise",
"if",
"needed",
"does",
"not",
"modify",
"the",
"indexer",
"externally"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L270-L295 | [
"def",
"_has_valid_positional_setitem_indexer",
"(",
"self",
",",
"indexer",
")",
":",
"if",
"isinstance",
"(",
"indexer",
",",
"dict",
")",
":",
"raise",
"IndexError",
"(",
"\"{0} cannot enlarge its target object\"",
".",
"format",
"(",
"self",
".",
"name",
")",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _NDFrameIndexer._align_series | 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... | pandas/core/indexing.py | 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):
"""
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... | [
"Parameters",
"----------",
"indexer",
":",
"tuple",
"slice",
"scalar",
"The",
"indexer",
"used",
"to",
"get",
"the",
"locations",
"that",
"will",
"be",
"set",
"to",
"ser"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L657-L781 | [
"def",
"_align_series",
"(",
"self",
",",
"indexer",
",",
"ser",
",",
"multiindex_indexer",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"indexer",
",",
"(",
"slice",
",",
"np",
".",
"ndarray",
",",
"list",
",",
"Index",
")",
")",
":",
"indexer",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _NDFrameIndexer._multi_take_opportunity | 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... | pandas/core/indexing.py | 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):
"""
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... | [
"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",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L890-L912 | [
"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... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _NDFrameIndexer._multi_take | 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... | pandas/core/indexing.py | 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):
"""
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... | [
"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",
... | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L914-L933 | [
"def",
"_multi_take",
"(",
"self",
",",
"tup",
")",
":",
"# GH 836",
"o",
"=",
"self",
".",
"obj",
"d",
"=",
"{",
"axis",
":",
"self",
".",
"_get_listlike_indexer",
"(",
"key",
",",
"axis",
")",
"for",
"(",
"key",
",",
"axis",
")",
"in",
"zip",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _NDFrameIndexer._get_listlike_indexer | 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... | pandas/core/indexing.py | 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):
"""
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
... | [
"Transform",
"a",
"list",
"-",
"like",
"of",
"keys",
"into",
"a",
"new",
"index",
"and",
"an",
"indexer",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1112-L1166 | [
"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... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _NDFrameIndexer._getitem_iterable | 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... | pandas/core/indexing.py | 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):
"""
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
... | [
"Index",
"current",
"object",
"with",
"an",
"an",
"iterable",
"key",
"(",
"which",
"can",
"be",
"a",
"boolean",
"indexer",
"or",
"a",
"collection",
"of",
"keys",
")",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1168-L1211 | [
"def",
"_getitem_iterable",
"(",
"self",
",",
"key",
",",
"axis",
"=",
"None",
")",
":",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"self",
".",
"axis",
"or",
"0",
"self",
".",
"_validate_key",
"(",
"key",
",",
"axis",
")",
"labels",
"=",
"self"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _NDFrameIndexer._validate_read_indexer | 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
... | pandas/core/indexing.py | 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):
"""
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... | [
"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",
")",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1213-L1273 | [
"def",
"_validate_read_indexer",
"(",
"self",
",",
"key",
",",
"indexer",
",",
"axis",
",",
"raise_missing",
"=",
"False",
")",
":",
"ax",
"=",
"self",
".",
"obj",
".",
"_get_axis",
"(",
"axis",
")",
"if",
"len",
"(",
"key",
")",
"==",
"0",
":",
"r... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _NDFrameIndexer._convert_to_indexer | 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... | pandas/core/indexing.py | 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):
"""
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[... | [
"Convert",
"indexing",
"key",
"into",
"something",
"we",
"can",
"use",
"to",
"do",
"actual",
"fancy",
"indexing",
"on",
"an",
"ndarray"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1275-L1366 | [
"def",
"_convert_to_indexer",
"(",
"self",
",",
"obj",
",",
"axis",
"=",
"None",
",",
"is_setter",
"=",
"False",
",",
"raise_missing",
"=",
"False",
")",
":",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"self",
".",
"axis",
"or",
"0",
"labels",
"="... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _IXIndexer._convert_for_reindex | 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-... | pandas/core/indexing.py | 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):
"""
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... | [
"Transform",
"a",
"list",
"of",
"keys",
"into",
"a",
"new",
"array",
"ready",
"to",
"be",
"used",
"as",
"axis",
"of",
"the",
"object",
"we",
"return",
"(",
"e",
".",
"g",
".",
"including",
"NaNs",
")",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1442-L1483 | [
"def",
"_convert_for_reindex",
"(",
"self",
",",
"key",
",",
"axis",
"=",
"None",
")",
":",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"self",
".",
"axis",
"or",
"0",
"labels",
"=",
"self",
".",
"obj",
".",
"_get_axis",
"(",
"axis",
")",
"if",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _LocationIndexer._get_slice_axis | this is pretty simple as we just have to deal with labels | pandas/core/indexing.py | 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):
""" 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... | [
"this",
"is",
"pretty",
"simple",
"as",
"we",
"just",
"have",
"to",
"deal",
"with",
"labels"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1526-L1542 | [
"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",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _LocIndexer._get_partial_string_timestamp_match_key | Translate any partial string timestamp matches in key, returning the
new key (GH 10331) | pandas/core/indexing.py | 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):
"""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 ... | [
"Translate",
"any",
"partial",
"string",
"timestamp",
"matches",
"in",
"key",
"returning",
"the",
"new",
"key",
"(",
"GH",
"10331",
")"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1835-L1856 | [
"def",
"_get_partial_string_timestamp_match_key",
"(",
"self",
",",
"key",
",",
"labels",
")",
":",
"if",
"isinstance",
"(",
"labels",
",",
"MultiIndex",
")",
":",
"if",
"(",
"isinstance",
"(",
"key",
",",
"str",
")",
"and",
"labels",
".",
"levels",
"[",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _iLocIndexer._validate_integer | 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... | pandas/core/indexing.py | 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):
"""
Check that 'key' is a valid position in the desired axis.
Parameters
----------
key : int
Requested position
axis : int
Desired axis
Returns
-------
None
Raises
... | [
"Check",
"that",
"key",
"is",
"a",
"valid",
"position",
"in",
"the",
"desired",
"axis",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2125-L2148 | [
"def",
"_validate_integer",
"(",
"self",
",",
"key",
",",
"axis",
")",
":",
"len_axis",
"=",
"len",
"(",
"self",
".",
"obj",
".",
"_get_axis",
"(",
"axis",
")",
")",
"if",
"key",
">=",
"len_axis",
"or",
"key",
"<",
"-",
"len_axis",
":",
"raise",
"I... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _iLocIndexer._get_list_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 | pandas/core/indexing.py | 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):
"""
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... | [
"Return",
"Series",
"values",
"by",
"list",
"or",
"array",
"of",
"integers"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2193-L2212 | [
"def",
"_get_list_axis",
"(",
"self",
",",
"key",
",",
"axis",
"=",
"None",
")",
":",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"self",
".",
"axis",
"or",
"0",
"try",
":",
"return",
"self",
".",
"obj",
".",
"_take",
"(",
"key",
",",
"axis",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _iLocIndexer._convert_to_indexer | much simpler as we only have to deal with our valid types | pandas/core/indexing.py | 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):
""" 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... | [
"much",
"simpler",
"as",
"we",
"only",
"have",
"to",
"deal",
"with",
"our",
"valid",
"types"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2244-L2261 | [
"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... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _AtIndexer._convert_key | require they keys to be the same type as the index (so we don't
fallback) | pandas/core/indexing.py | 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):
""" 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():
... | [
"require",
"they",
"keys",
"to",
"be",
"the",
"same",
"type",
"as",
"the",
"index",
"(",
"so",
"we",
"don",
"t",
"fallback",
")"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2349-L2368 | [
"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",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _iAtIndexer._convert_key | require integer args (and convert to label arguments) | pandas/core/indexing.py | 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):
""" 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")
... | [
"require",
"integer",
"args",
"(",
"and",
"convert",
"to",
"label",
"arguments",
")"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2422-L2428 | [
"def",
"_convert_key",
"(",
"self",
",",
"key",
",",
"is_setter",
"=",
"False",
")",
":",
"for",
"a",
",",
"i",
"in",
"zip",
"(",
"self",
".",
"obj",
".",
"axes",
",",
"key",
")",
":",
"if",
"not",
"is_integer",
"(",
"i",
")",
":",
"raise",
"Va... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | to_manager | create and return the block manager from a dataframe of series,
columns, index | pandas/core/sparse/frame.py | 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):
""" 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... | [
"create",
"and",
"return",
"the",
"block",
"manager",
"from",
"a",
"dataframe",
"of",
"series",
"columns",
"index"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L951-L960 | [
"def",
"to_manager",
"(",
"sdf",
",",
"columns",
",",
"index",
")",
":",
"# from BlockManager perspective",
"axes",
"=",
"[",
"ensure_index",
"(",
"columns",
")",
",",
"ensure_index",
"(",
"index",
")",
"]",
"return",
"create_block_manager_from_arrays",
"(",
"["... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | stack_sparse_frame | Only makes sense when fill_value is NaN | pandas/core/sparse/frame.py | 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):
"""
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 = []
... | [
"Only",
"makes",
"sense",
"when",
"fill_value",
"is",
"NaN"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L963-L994 | [
"def",
"stack_sparse_frame",
"(",
"frame",
")",
":",
"lengths",
"=",
"[",
"s",
".",
"sp_index",
".",
"npoints",
"for",
"_",
",",
"s",
"in",
"frame",
".",
"items",
"(",
")",
"]",
"nobs",
"=",
"sum",
"(",
"lengths",
")",
"# this is pretty fast",
"minor_c... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | homogenize | 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
... | pandas/core/sparse/frame.py | 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):
"""
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... | [
"Conform",
"a",
"set",
"of",
"SparseSeries",
"(",
"with",
"NaN",
"fill_value",
")",
"to",
"a",
"common",
"SparseIndex",
"corresponding",
"to",
"the",
"locations",
"where",
"they",
"all",
"have",
"data"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L997-L1039 | [
"def",
"homogenize",
"(",
"series_dict",
")",
":",
"index",
"=",
"None",
"need_reindex",
"=",
"False",
"for",
"_",
",",
"series",
"in",
"series_dict",
".",
"items",
"(",
")",
":",
"if",
"not",
"np",
".",
"isnan",
"(",
"series",
".",
"fill_value",
")",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | SparseDataFrame._init_matrix | Init self from ndarray or list of lists. | pandas/core/sparse/frame.py | 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):
"""
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... | [
"Init",
"self",
"from",
"ndarray",
"or",
"list",
"of",
"lists",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L190-L197 | [
"def",
"_init_matrix",
"(",
"self",
",",
"data",
",",
"index",
",",
"columns",
",",
"dtype",
"=",
"None",
")",
":",
"data",
"=",
"prep_ndarray",
"(",
"data",
",",
"copy",
"=",
"False",
")",
"index",
",",
"columns",
"=",
"self",
".",
"_prep_index",
"(... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | SparseDataFrame._init_spmatrix | Init self from scipy.sparse matrix. | pandas/core/sparse/frame.py | 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):
"""
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... | [
"Init",
"self",
"from",
"scipy",
".",
"sparse",
"matrix",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L199-L229 | [
"def",
"_init_spmatrix",
"(",
"self",
",",
"data",
",",
"index",
",",
"columns",
",",
"dtype",
"=",
"None",
",",
"fill_value",
"=",
"None",
")",
":",
"index",
",",
"columns",
"=",
"self",
".",
"_prep_index",
"(",
"data",
",",
"index",
",",
"columns",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | SparseDataFrame.to_coo | 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... | pandas/core/sparse/frame.py | 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):
"""
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... | [
"Return",
"the",
"contents",
"of",
"the",
"frame",
"as",
"a",
"sparse",
"SciPy",
"COO",
"matrix",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L246-L288 | [
"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"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | SparseDataFrame._unpickle_sparse_frame_compat | Original pickle format | pandas/core/sparse/frame.py | 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):
"""
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... | [
"Original",
"pickle",
"format"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L302-L327 | [
"def",
"_unpickle_sparse_frame_compat",
"(",
"self",
",",
"state",
")",
":",
"series",
",",
"cols",
",",
"idx",
",",
"fv",
",",
"kind",
"=",
"state",
"if",
"not",
"isinstance",
"(",
"cols",
",",
"Index",
")",
":",
"# pragma: no cover",
"from",
"pandas",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | SparseDataFrame.to_dense | Convert to dense DataFrame
Returns
-------
df : DataFrame | pandas/core/sparse/frame.py | 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):
"""
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) | [
"Convert",
"to",
"dense",
"DataFrame"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L329-L338 | [
"def",
"to_dense",
"(",
"self",
")",
":",
"data",
"=",
"{",
"k",
":",
"v",
".",
"to_dense",
"(",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
"}",
"return",
"DataFrame",
"(",
"data",
",",
"index",
"=",
"self",
".",
"index",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | SparseDataFrame._apply_columns | Get new SparseDataFrame applying func to each columns | pandas/core/sparse/frame.py | 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):
"""
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,
... | [
"Get",
"new",
"SparseDataFrame",
"applying",
"func",
"to",
"each",
"columns"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L340-L350 | [
"def",
"_apply_columns",
"(",
"self",
",",
"func",
")",
":",
"new_data",
"=",
"{",
"col",
":",
"func",
"(",
"series",
")",
"for",
"col",
",",
"series",
"in",
"self",
".",
"items",
"(",
")",
"}",
"return",
"self",
".",
"_constructor",
"(",
"data",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | SparseDataFrame.copy | Make a copy of this SparseDataFrame | pandas/core/sparse/frame.py | 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):
"""
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 | [
"Make",
"a",
"copy",
"of",
"this",
"SparseDataFrame"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L355-L362 | [
"def",
"copy",
"(",
"self",
",",
"deep",
"=",
"True",
")",
":",
"result",
"=",
"super",
"(",
")",
".",
"copy",
"(",
"deep",
"=",
"deep",
")",
"result",
".",
"_default_fill_value",
"=",
"self",
".",
"_default_fill_value",
"result",
".",
"_default_kind",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | SparseDataFrame.density | Ratio of non-sparse points to total (dense) data points
represented in the frame | pandas/core/sparse/frame.py | 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):
"""
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... | [
"Ratio",
"of",
"non",
"-",
"sparse",
"points",
"to",
"total",
"(",
"dense",
")",
"data",
"points",
"represented",
"in",
"the",
"frame"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L373-L381 | [
"def",
"density",
"(",
"self",
")",
":",
"tot_nonsparse",
"=",
"sum",
"(",
"ser",
".",
"sp_index",
".",
"npoints",
"for",
"_",
",",
"ser",
"in",
"self",
".",
"items",
"(",
")",
")",
"tot",
"=",
"len",
"(",
"self",
".",
"index",
")",
"*",
"len",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | SparseDataFrame._sanitize_column | Creates a new SparseArray from the input value.
Parameters
----------
key : object
value : scalar, Series, or array-like
kwargs : dict
Returns
-------
sanitized_column : SparseArray | pandas/core/sparse/frame.py | 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):
"""
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",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L403-L448 | [
"def",
"_sanitize_column",
"(",
"self",
",",
"key",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"sp_maker",
"(",
"x",
",",
"index",
"=",
"None",
")",
":",
"return",
"SparseArray",
"(",
"x",
",",
"index",
"=",
"index",
",",
"fill_value",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | SparseDataFrame.xs | Returns a row (cross-section) from the SparseDataFrame as a Series
object.
Parameters
----------
key : some index contained in the index
Returns
-------
xs : Series | pandas/core/sparse/frame.py | 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):
"""
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:
... | [
"Returns",
"a",
"row",
"(",
"cross",
"-",
"section",
")",
"from",
"the",
"SparseDataFrame",
"as",
"a",
"Series",
"object",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L531-L550 | [
"def",
"xs",
"(",
"self",
",",
"key",
",",
"axis",
"=",
"0",
",",
"copy",
"=",
"False",
")",
":",
"if",
"axis",
"==",
"1",
":",
"data",
"=",
"self",
"[",
"key",
"]",
"return",
"data",
"i",
"=",
"self",
".",
"index",
".",
"get_loc",
"(",
"key"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | SparseDataFrame.transpose | Returns a DataFrame with the rows/columns switched. | pandas/core/sparse/frame.py | 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):
"""
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... | [
"Returns",
"a",
"DataFrame",
"with",
"the",
"rows",
"/",
"columns",
"switched",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L809-L817 | [
"def",
"transpose",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"nv",
".",
"validate_transpose",
"(",
"args",
",",
"kwargs",
")",
"return",
"self",
".",
"_constructor",
"(",
"self",
".",
"values",
".",
"T",
",",
"index",
"=",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | SparseDataFrame.cumsum | Return SparseDataFrame of cumulative sums over requested axis.
Parameters
----------
axis : {0, 1}
0 for row-wise, 1 for column-wise
Returns
-------
y : SparseDataFrame | pandas/core/sparse/frame.py | 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):
"""
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... | [
"Return",
"SparseDataFrame",
"of",
"cumulative",
"sums",
"over",
"requested",
"axis",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L828-L846 | [
"def",
"cumsum",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"nv",
".",
"validate_cumsum",
"(",
"args",
",",
"kwargs",
")",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"self",
".",
"_stat_axis_number",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | SparseDataFrame.apply | 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
... | pandas/core/sparse/frame.py | 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):
"""
Analogous to DataFrame.apply, for SparseDataFrame
Parameters
----------
func : function
Function to apply to each column
axis : {0, 1, 'index', 'columns'}
... | [
"Analogous",
"to",
"DataFrame",
".",
"apply",
"for",
"SparseDataFrame"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L858-L931 | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"axis",
"=",
"0",
",",
"broadcast",
"=",
"None",
",",
"reduce",
"=",
"None",
",",
"result_type",
"=",
"None",
")",
":",
"if",
"not",
"len",
"(",
"self",
".",
"columns",
")",
":",
"return",
"self",
"a... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | conda_package_to_pip | 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... | scripts/generate_pip_deps_from_conda.py | 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):
"""
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... | [
"Convert",
"a",
"conda",
"package",
"to",
"its",
"pip",
"equivalent",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/generate_pip_deps_from_conda.py#L26-L51 | [
"def",
"conda_package_to_pip",
"(",
"package",
")",
":",
"if",
"package",
"in",
"EXCLUDE",
":",
"return",
"package",
"=",
"re",
".",
"sub",
"(",
"'(?<=[^<>])='",
",",
"'=='",
",",
"package",
")",
".",
"strip",
"(",
")",
"for",
"compare",
"in",
"(",
"'<... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | main | 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. `... | scripts/generate_pip_deps_from_conda.py | 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):
"""
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... | [
"Generate",
"the",
"pip",
"dependencies",
"file",
"from",
"the",
"conda",
"file",
"or",
"compare",
"that",
"they",
"are",
"synchronized",
"(",
"compare",
"=",
"True",
")",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/generate_pip_deps_from_conda.py#L54-L97 | [
"def",
"main",
"(",
"conda_fname",
",",
"pip_fname",
",",
"compare",
"=",
"False",
")",
":",
"with",
"open",
"(",
"conda_fname",
")",
"as",
"conda_fd",
":",
"deps",
"=",
"yaml",
".",
"safe_load",
"(",
"conda_fd",
")",
"[",
"'dependencies'",
"]",
"pip_dep... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | maybe_convert_platform | try to do platform conversion, allow ndarray or list here | pandas/core/dtypes/cast.py | 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):
""" 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'):
... | [
"try",
"to",
"do",
"platform",
"conversion",
"allow",
"ndarray",
"or",
"list",
"here"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L35-L45 | [
"def",
"maybe_convert_platform",
"(",
"values",
")",
":",
"if",
"isinstance",
"(",
"values",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"values",
"=",
"construct_1d_object_array_from_listlike",
"(",
"list",
"(",
"values",
")",
")",
"if",
"getattr",
"(",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | is_nested_object | 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. | pandas/core/dtypes/cast.py | 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):
"""
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):
... | [
"return",
"a",
"boolean",
"if",
"we",
"have",
"a",
"nested",
"object",
"e",
".",
"g",
".",
"a",
"Series",
"with",
"1",
"or",
"more",
"Series",
"elements"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L48-L62 | [
"def",
"is_nested_object",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"ABCSeries",
")",
"and",
"is_object_dtype",
"(",
"obj",
")",
":",
"if",
"any",
"(",
"isinstance",
"(",
"v",
",",
"ABCSeries",
")",
"for",
"v",
"in",
"obj",
".",
"va... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | maybe_downcast_to_dtype | try to cast to the specified dtype (e.g. convert back to bool/int
or could be an astype of float64->float32 | pandas/core/dtypes/cast.py | 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):
""" 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':
... | [
"try",
"to",
"cast",
"to",
"the",
"specified",
"dtype",
"(",
"e",
".",
"g",
".",
"convert",
"back",
"to",
"bool",
"/",
"int",
"or",
"could",
"be",
"an",
"astype",
"of",
"float64",
"-",
">",
"float32"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L65-L167 | [
"def",
"maybe_downcast_to_dtype",
"(",
"result",
",",
"dtype",
")",
":",
"if",
"is_scalar",
"(",
"result",
")",
":",
"return",
"result",
"def",
"trans",
"(",
"x",
")",
":",
"return",
"x",
"if",
"isinstance",
"(",
"dtype",
",",
"str",
")",
":",
"if",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | maybe_upcast_putmask | 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... | pandas/core/dtypes/cast.py | 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):
"""
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... | [
"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",
... | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L170-L265 | [
"def",
"maybe_upcast_putmask",
"(",
"result",
",",
"mask",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"result",
",",
"np",
".",
"ndarray",
")",
":",
"raise",
"ValueError",
"(",
"\"The result input must be a ndarray.\"",
")",
"if",
"mask",
".",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | infer_dtype_from | interpret the dtype from a scalar or array. This is a convenience
routines to infer dtype from a scalar or an array
Parameters
----------
pandas_dtype : bool, default False
whether to infer dtype including pandas extension types.
If False, scalar/array belongs to pandas extension types ... | pandas/core/dtypes/cast.py | def infer_dtype_from(val, pandas_dtype=False):
"""
interpret the dtype from a scalar or array. This is a convenience
routines to infer dtype from a scalar or an array
Parameters
----------
pandas_dtype : bool, default False
whether to infer dtype including pandas extension types.
... | def infer_dtype_from(val, pandas_dtype=False):
"""
interpret the dtype from a scalar or array. This is a convenience
routines to infer dtype from a scalar or an array
Parameters
----------
pandas_dtype : bool, default False
whether to infer dtype including pandas extension types.
... | [
"interpret",
"the",
"dtype",
"from",
"a",
"scalar",
"or",
"array",
".",
"This",
"is",
"a",
"convenience",
"routines",
"to",
"infer",
"dtype",
"from",
"a",
"scalar",
"or",
"an",
"array"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L337-L351 | [
"def",
"infer_dtype_from",
"(",
"val",
",",
"pandas_dtype",
"=",
"False",
")",
":",
"if",
"is_scalar",
"(",
"val",
")",
":",
"return",
"infer_dtype_from_scalar",
"(",
"val",
",",
"pandas_dtype",
"=",
"pandas_dtype",
")",
"return",
"infer_dtype_from_array",
"(",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | infer_dtype_from_scalar | interpret the dtype from a scalar
Parameters
----------
pandas_dtype : bool, default False
whether to infer dtype including pandas extension types.
If False, scalar belongs to pandas extension types is inferred as
object | pandas/core/dtypes/cast.py | def infer_dtype_from_scalar(val, pandas_dtype=False):
"""
interpret the dtype from a scalar
Parameters
----------
pandas_dtype : bool, default False
whether to infer dtype including pandas extension types.
If False, scalar belongs to pandas extension types is inferred as
obj... | def infer_dtype_from_scalar(val, pandas_dtype=False):
"""
interpret the dtype from a scalar
Parameters
----------
pandas_dtype : bool, default False
whether to infer dtype including pandas extension types.
If False, scalar belongs to pandas extension types is inferred as
obj... | [
"interpret",
"the",
"dtype",
"from",
"a",
"scalar"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L354-L426 | [
"def",
"infer_dtype_from_scalar",
"(",
"val",
",",
"pandas_dtype",
"=",
"False",
")",
":",
"dtype",
"=",
"np",
".",
"object_",
"# a 1-element ndarray",
"if",
"isinstance",
"(",
"val",
",",
"np",
".",
"ndarray",
")",
":",
"msg",
"=",
"\"invalid ndarray passed t... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | infer_dtype_from_array | infer the dtype from a scalar or array
Parameters
----------
arr : scalar or array
pandas_dtype : bool, default False
whether to infer dtype including pandas extension types.
If False, array belongs to pandas extension types
is inferred as object
Returns
-------
tup... | pandas/core/dtypes/cast.py | def infer_dtype_from_array(arr, pandas_dtype=False):
"""
infer the dtype from a scalar or array
Parameters
----------
arr : scalar or array
pandas_dtype : bool, default False
whether to infer dtype including pandas extension types.
If False, array belongs to pandas extension typ... | def infer_dtype_from_array(arr, pandas_dtype=False):
"""
infer the dtype from a scalar or array
Parameters
----------
arr : scalar or array
pandas_dtype : bool, default False
whether to infer dtype including pandas extension types.
If False, array belongs to pandas extension typ... | [
"infer",
"the",
"dtype",
"from",
"a",
"scalar",
"or",
"array"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L429-L483 | [
"def",
"infer_dtype_from_array",
"(",
"arr",
",",
"pandas_dtype",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"arr",
",",
"np",
".",
"ndarray",
")",
":",
"return",
"arr",
".",
"dtype",
",",
"arr",
"if",
"not",
"is_list_like",
"(",
"arr",
")",
":",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | maybe_infer_dtype_type | Try to infer an object's dtype, for use in arithmetic ops
Uses `element.dtype` if that's available.
Objects implementing the iterator protocol are cast to a NumPy array,
and from there the array's type is used.
Parameters
----------
element : object
Possibly has a `.dtype` attribute, a... | pandas/core/dtypes/cast.py | def maybe_infer_dtype_type(element):
"""Try to infer an object's dtype, for use in arithmetic ops
Uses `element.dtype` if that's available.
Objects implementing the iterator protocol are cast to a NumPy array,
and from there the array's type is used.
Parameters
----------
element : object
... | def maybe_infer_dtype_type(element):
"""Try to infer an object's dtype, for use in arithmetic ops
Uses `element.dtype` if that's available.
Objects implementing the iterator protocol are cast to a NumPy array,
and from there the array's type is used.
Parameters
----------
element : object
... | [
"Try",
"to",
"infer",
"an",
"object",
"s",
"dtype",
"for",
"use",
"in",
"arithmetic",
"ops"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L486-L516 | [
"def",
"maybe_infer_dtype_type",
"(",
"element",
")",
":",
"tipo",
"=",
"None",
"if",
"hasattr",
"(",
"element",
",",
"'dtype'",
")",
":",
"tipo",
"=",
"element",
".",
"dtype",
"elif",
"is_list_like",
"(",
"element",
")",
":",
"element",
"=",
"np",
".",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | maybe_upcast | provide explicit type promotion and coercion
Parameters
----------
values : the ndarray that we want to maybe upcast
fill_value : what we want to fill with
dtype : if None, then use the dtype of the values, else coerce to this type
copy : if True always make a copy even if no upcast is required | pandas/core/dtypes/cast.py | def maybe_upcast(values, fill_value=np.nan, dtype=None, copy=False):
""" provide explicit type promotion and coercion
Parameters
----------
values : the ndarray that we want to maybe upcast
fill_value : what we want to fill with
dtype : if None, then use the dtype of the values, else coerce to ... | def maybe_upcast(values, fill_value=np.nan, dtype=None, copy=False):
""" provide explicit type promotion and coercion
Parameters
----------
values : the ndarray that we want to maybe upcast
fill_value : what we want to fill with
dtype : if None, then use the dtype of the values, else coerce to ... | [
"provide",
"explicit",
"type",
"promotion",
"and",
"coercion"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L519-L542 | [
"def",
"maybe_upcast",
"(",
"values",
",",
"fill_value",
"=",
"np",
".",
"nan",
",",
"dtype",
"=",
"None",
",",
"copy",
"=",
"False",
")",
":",
"if",
"is_extension_type",
"(",
"values",
")",
":",
"if",
"copy",
":",
"values",
"=",
"values",
".",
"copy... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | invalidate_string_dtypes | Change string like dtypes to object for
``DataFrame.select_dtypes()``. | pandas/core/dtypes/cast.py | def invalidate_string_dtypes(dtype_set):
"""Change string like dtypes to object for
``DataFrame.select_dtypes()``.
"""
non_string_dtypes = dtype_set - {np.dtype('S').type, np.dtype('<U').type}
if non_string_dtypes != dtype_set:
raise TypeError("string dtypes are not allowed, use 'object' ins... | def invalidate_string_dtypes(dtype_set):
"""Change string like dtypes to object for
``DataFrame.select_dtypes()``.
"""
non_string_dtypes = dtype_set - {np.dtype('S').type, np.dtype('<U').type}
if non_string_dtypes != dtype_set:
raise TypeError("string dtypes are not allowed, use 'object' ins... | [
"Change",
"string",
"like",
"dtypes",
"to",
"object",
"for",
"DataFrame",
".",
"select_dtypes",
"()",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L556-L562 | [
"def",
"invalidate_string_dtypes",
"(",
"dtype_set",
")",
":",
"non_string_dtypes",
"=",
"dtype_set",
"-",
"{",
"np",
".",
"dtype",
"(",
"'S'",
")",
".",
"type",
",",
"np",
".",
"dtype",
"(",
"'<U'",
")",
".",
"type",
"}",
"if",
"non_string_dtypes",
"!="... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | coerce_indexer_dtype | coerce the indexer input array to the smallest dtype possible | pandas/core/dtypes/cast.py | def coerce_indexer_dtype(indexer, categories):
""" coerce the indexer input array to the smallest dtype possible """
length = len(categories)
if length < _int8_max:
return ensure_int8(indexer)
elif length < _int16_max:
return ensure_int16(indexer)
elif length < _int32_max:
re... | def coerce_indexer_dtype(indexer, categories):
""" coerce the indexer input array to the smallest dtype possible """
length = len(categories)
if length < _int8_max:
return ensure_int8(indexer)
elif length < _int16_max:
return ensure_int16(indexer)
elif length < _int32_max:
re... | [
"coerce",
"the",
"indexer",
"input",
"array",
"to",
"the",
"smallest",
"dtype",
"possible"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L565-L574 | [
"def",
"coerce_indexer_dtype",
"(",
"indexer",
",",
"categories",
")",
":",
"length",
"=",
"len",
"(",
"categories",
")",
"if",
"length",
"<",
"_int8_max",
":",
"return",
"ensure_int8",
"(",
"indexer",
")",
"elif",
"length",
"<",
"_int16_max",
":",
"return",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | coerce_to_dtypes | given a dtypes and a result set, coerce the result elements to the
dtypes | pandas/core/dtypes/cast.py | def coerce_to_dtypes(result, dtypes):
"""
given a dtypes and a result set, coerce the result elements to the
dtypes
"""
if len(result) != len(dtypes):
raise AssertionError("_coerce_to_dtypes requires equal len arrays")
def conv(r, dtype):
try:
if isna(r):
... | def coerce_to_dtypes(result, dtypes):
"""
given a dtypes and a result set, coerce the result elements to the
dtypes
"""
if len(result) != len(dtypes):
raise AssertionError("_coerce_to_dtypes requires equal len arrays")
def conv(r, dtype):
try:
if isna(r):
... | [
"given",
"a",
"dtypes",
"and",
"a",
"result",
"set",
"coerce",
"the",
"result",
"elements",
"to",
"the",
"dtypes"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L577-L607 | [
"def",
"coerce_to_dtypes",
"(",
"result",
",",
"dtypes",
")",
":",
"if",
"len",
"(",
"result",
")",
"!=",
"len",
"(",
"dtypes",
")",
":",
"raise",
"AssertionError",
"(",
"\"_coerce_to_dtypes requires equal len arrays\"",
")",
"def",
"conv",
"(",
"r",
",",
"d... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | astype_nansafe | Cast the elements of an array to a given dtype a nan-safe manner.
Parameters
----------
arr : ndarray
dtype : np.dtype
copy : bool, default True
If False, a view will be attempted but may fail, if
e.g. the item sizes don't align.
skipna: bool, default False
Whether or no... | pandas/core/dtypes/cast.py | def astype_nansafe(arr, dtype, copy=True, skipna=False):
"""
Cast the elements of an array to a given dtype a nan-safe manner.
Parameters
----------
arr : ndarray
dtype : np.dtype
copy : bool, default True
If False, a view will be attempted but may fail, if
e.g. the item siz... | def astype_nansafe(arr, dtype, copy=True, skipna=False):
"""
Cast the elements of an array to a given dtype a nan-safe manner.
Parameters
----------
arr : ndarray
dtype : np.dtype
copy : bool, default True
If False, a view will be attempted but may fail, if
e.g. the item siz... | [
"Cast",
"the",
"elements",
"of",
"an",
"array",
"to",
"a",
"given",
"dtype",
"a",
"nan",
"-",
"safe",
"manner",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L610-L710 | [
"def",
"astype_nansafe",
"(",
"arr",
",",
"dtype",
",",
"copy",
"=",
"True",
",",
"skipna",
"=",
"False",
")",
":",
"# dispatch on extension dtype if needed",
"if",
"is_extension_array_dtype",
"(",
"dtype",
")",
":",
"return",
"dtype",
".",
"construct_array_type",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | maybe_convert_objects | if we have an object dtype, try to coerce dates and/or numbers | pandas/core/dtypes/cast.py | def maybe_convert_objects(values, convert_dates=True, convert_numeric=True,
convert_timedeltas=True, copy=True):
""" if we have an object dtype, try to coerce dates and/or numbers """
# if we have passed in a list or scalar
if isinstance(values, (list, tuple)):
values = np... | def maybe_convert_objects(values, convert_dates=True, convert_numeric=True,
convert_timedeltas=True, copy=True):
""" if we have an object dtype, try to coerce dates and/or numbers """
# if we have passed in a list or scalar
if isinstance(values, (list, tuple)):
values = np... | [
"if",
"we",
"have",
"an",
"object",
"dtype",
"try",
"to",
"coerce",
"dates",
"and",
"/",
"or",
"numbers"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L713-L773 | [
"def",
"maybe_convert_objects",
"(",
"values",
",",
"convert_dates",
"=",
"True",
",",
"convert_numeric",
"=",
"True",
",",
"convert_timedeltas",
"=",
"True",
",",
"copy",
"=",
"True",
")",
":",
"# if we have passed in a list or scalar",
"if",
"isinstance",
"(",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | soft_convert_objects | if we have an object dtype, try to coerce dates and/or numbers | pandas/core/dtypes/cast.py | def soft_convert_objects(values, datetime=True, numeric=True, timedelta=True,
coerce=False, copy=True):
""" if we have an object dtype, try to coerce dates and/or numbers """
conversion_count = sum((datetime, numeric, timedelta))
if conversion_count == 0:
raise ValueError('... | def soft_convert_objects(values, datetime=True, numeric=True, timedelta=True,
coerce=False, copy=True):
""" if we have an object dtype, try to coerce dates and/or numbers """
conversion_count = sum((datetime, numeric, timedelta))
if conversion_count == 0:
raise ValueError('... | [
"if",
"we",
"have",
"an",
"object",
"dtype",
"try",
"to",
"coerce",
"dates",
"and",
"/",
"or",
"numbers"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L776-L835 | [
"def",
"soft_convert_objects",
"(",
"values",
",",
"datetime",
"=",
"True",
",",
"numeric",
"=",
"True",
",",
"timedelta",
"=",
"True",
",",
"coerce",
"=",
"False",
",",
"copy",
"=",
"True",
")",
":",
"conversion_count",
"=",
"sum",
"(",
"(",
"datetime",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | maybe_infer_to_datetimelike | we might have a array (or single object) that is datetime like,
and no dtype is passed don't change the value unless we find a
datetime/timedelta set
this is pretty strict in that a datetime/timedelta is REQUIRED
in addition to possible nulls/string likes
Parameters
----------
value : np.a... | pandas/core/dtypes/cast.py | def maybe_infer_to_datetimelike(value, convert_dates=False):
"""
we might have a array (or single object) that is datetime like,
and no dtype is passed don't change the value unless we find a
datetime/timedelta set
this is pretty strict in that a datetime/timedelta is REQUIRED
in addition to po... | def maybe_infer_to_datetimelike(value, convert_dates=False):
"""
we might have a array (or single object) that is datetime like,
and no dtype is passed don't change the value unless we find a
datetime/timedelta set
this is pretty strict in that a datetime/timedelta is REQUIRED
in addition to po... | [
"we",
"might",
"have",
"a",
"array",
"(",
"or",
"single",
"object",
")",
"that",
"is",
"datetime",
"like",
"and",
"no",
"dtype",
"is",
"passed",
"don",
"t",
"change",
"the",
"value",
"unless",
"we",
"find",
"a",
"datetime",
"/",
"timedelta",
"set"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L852-L956 | [
"def",
"maybe_infer_to_datetimelike",
"(",
"value",
",",
"convert_dates",
"=",
"False",
")",
":",
"# TODO: why not timedelta?",
"if",
"isinstance",
"(",
"value",
",",
"(",
"ABCDatetimeIndex",
",",
"ABCPeriodIndex",
",",
"ABCDatetimeArray",
",",
"ABCPeriodArray",
")",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | maybe_cast_to_datetime | try to cast the array/value to a datetimelike dtype, converting float
nan to iNaT | pandas/core/dtypes/cast.py | def maybe_cast_to_datetime(value, dtype, errors='raise'):
""" try to cast the array/value to a datetimelike dtype, converting float
nan to iNaT
"""
from pandas.core.tools.timedeltas import to_timedelta
from pandas.core.tools.datetimes import to_datetime
if dtype is not None:
if isinstan... | def maybe_cast_to_datetime(value, dtype, errors='raise'):
""" try to cast the array/value to a datetimelike dtype, converting float
nan to iNaT
"""
from pandas.core.tools.timedeltas import to_timedelta
from pandas.core.tools.datetimes import to_datetime
if dtype is not None:
if isinstan... | [
"try",
"to",
"cast",
"the",
"array",
"/",
"value",
"to",
"a",
"datetimelike",
"dtype",
"converting",
"float",
"nan",
"to",
"iNaT"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L959-L1080 | [
"def",
"maybe_cast_to_datetime",
"(",
"value",
",",
"dtype",
",",
"errors",
"=",
"'raise'",
")",
":",
"from",
"pandas",
".",
"core",
".",
"tools",
".",
"timedeltas",
"import",
"to_timedelta",
"from",
"pandas",
".",
"core",
".",
"tools",
".",
"datetimes",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | find_common_type | Find a common data type among the given dtypes.
Parameters
----------
types : list of dtypes
Returns
-------
pandas extension or numpy dtype
See Also
--------
numpy.find_common_type | pandas/core/dtypes/cast.py | def find_common_type(types):
"""
Find a common data type among the given dtypes.
Parameters
----------
types : list of dtypes
Returns
-------
pandas extension or numpy dtype
See Also
--------
numpy.find_common_type
"""
if len(types) == 0:
raise ValueError... | def find_common_type(types):
"""
Find a common data type among the given dtypes.
Parameters
----------
types : list of dtypes
Returns
-------
pandas extension or numpy dtype
See Also
--------
numpy.find_common_type
"""
if len(types) == 0:
raise ValueError... | [
"Find",
"a",
"common",
"data",
"type",
"among",
"the",
"given",
"dtypes",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L1083-L1129 | [
"def",
"find_common_type",
"(",
"types",
")",
":",
"if",
"len",
"(",
"types",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"'no types given'",
")",
"first",
"=",
"types",
"[",
"0",
"]",
"# workaround for find_common_type([np.dtype('datetime64[ns]')] * 2)",
"# ... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | cast_scalar_to_array | create np.ndarray of specified shape and dtype, filled with values
Parameters
----------
shape : tuple
value : scalar value
dtype : np.dtype, optional
dtype to coerce
Returns
-------
ndarray of shape, filled with value, of specified / inferred dtype | pandas/core/dtypes/cast.py | def cast_scalar_to_array(shape, value, dtype=None):
"""
create np.ndarray of specified shape and dtype, filled with values
Parameters
----------
shape : tuple
value : scalar value
dtype : np.dtype, optional
dtype to coerce
Returns
-------
ndarray of shape, filled with v... | def cast_scalar_to_array(shape, value, dtype=None):
"""
create np.ndarray of specified shape and dtype, filled with values
Parameters
----------
shape : tuple
value : scalar value
dtype : np.dtype, optional
dtype to coerce
Returns
-------
ndarray of shape, filled with v... | [
"create",
"np",
".",
"ndarray",
"of",
"specified",
"shape",
"and",
"dtype",
"filled",
"with",
"values"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L1132-L1157 | [
"def",
"cast_scalar_to_array",
"(",
"shape",
",",
"value",
",",
"dtype",
"=",
"None",
")",
":",
"if",
"dtype",
"is",
"None",
":",
"dtype",
",",
"fill_value",
"=",
"infer_dtype_from_scalar",
"(",
"value",
")",
"else",
":",
"fill_value",
"=",
"value",
"value... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | construct_1d_arraylike_from_scalar | create a np.ndarray / pandas type of specified shape and dtype
filled with values
Parameters
----------
value : scalar value
length : int
dtype : pandas_dtype / np.dtype
Returns
-------
np.ndarray / pandas type of length, filled with value | pandas/core/dtypes/cast.py | def construct_1d_arraylike_from_scalar(value, length, dtype):
"""
create a np.ndarray / pandas type of specified shape and dtype
filled with values
Parameters
----------
value : scalar value
length : int
dtype : pandas_dtype / np.dtype
Returns
-------
np.ndarray / pandas ty... | def construct_1d_arraylike_from_scalar(value, length, dtype):
"""
create a np.ndarray / pandas type of specified shape and dtype
filled with values
Parameters
----------
value : scalar value
length : int
dtype : pandas_dtype / np.dtype
Returns
-------
np.ndarray / pandas ty... | [
"create",
"a",
"np",
".",
"ndarray",
"/",
"pandas",
"type",
"of",
"specified",
"shape",
"and",
"dtype",
"filled",
"with",
"values"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L1160-L1199 | [
"def",
"construct_1d_arraylike_from_scalar",
"(",
"value",
",",
"length",
",",
"dtype",
")",
":",
"if",
"is_datetime64tz_dtype",
"(",
"dtype",
")",
":",
"from",
"pandas",
"import",
"DatetimeIndex",
"subarr",
"=",
"DatetimeIndex",
"(",
"[",
"value",
"]",
"*",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | construct_1d_object_array_from_listlike | Transform any list-like object in a 1-dimensional numpy array of object
dtype.
Parameters
----------
values : any iterable which has a len()
Raises
------
TypeError
* If `values` does not have a len()
Returns
-------
1-dimensional numpy array of dtype object | pandas/core/dtypes/cast.py | def construct_1d_object_array_from_listlike(values):
"""
Transform any list-like object in a 1-dimensional numpy array of object
dtype.
Parameters
----------
values : any iterable which has a len()
Raises
------
TypeError
* If `values` does not have a len()
Returns
... | def construct_1d_object_array_from_listlike(values):
"""
Transform any list-like object in a 1-dimensional numpy array of object
dtype.
Parameters
----------
values : any iterable which has a len()
Raises
------
TypeError
* If `values` does not have a len()
Returns
... | [
"Transform",
"any",
"list",
"-",
"like",
"object",
"in",
"a",
"1",
"-",
"dimensional",
"numpy",
"array",
"of",
"object",
"dtype",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L1202-L1224 | [
"def",
"construct_1d_object_array_from_listlike",
"(",
"values",
")",
":",
"# numpy will try to interpret nested lists as further dimensions, hence",
"# making a 1D array that contains list-likes is a bit tricky:",
"result",
"=",
"np",
".",
"empty",
"(",
"len",
"(",
"values",
")",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | construct_1d_ndarray_preserving_na | Construct a new ndarray, coercing `values` to `dtype`, preserving NA.
Parameters
----------
values : Sequence
dtype : numpy.dtype, optional
copy : bool, default False
Note that copies may still be made with ``copy=False`` if casting
is required.
Returns
-------
arr : nd... | pandas/core/dtypes/cast.py | def construct_1d_ndarray_preserving_na(values, dtype=None, copy=False):
"""
Construct a new ndarray, coercing `values` to `dtype`, preserving NA.
Parameters
----------
values : Sequence
dtype : numpy.dtype, optional
copy : bool, default False
Note that copies may still be made with ... | def construct_1d_ndarray_preserving_na(values, dtype=None, copy=False):
"""
Construct a new ndarray, coercing `values` to `dtype`, preserving NA.
Parameters
----------
values : Sequence
dtype : numpy.dtype, optional
copy : bool, default False
Note that copies may still be made with ... | [
"Construct",
"a",
"new",
"ndarray",
"coercing",
"values",
"to",
"dtype",
"preserving",
"NA",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L1227-L1266 | [
"def",
"construct_1d_ndarray_preserving_na",
"(",
"values",
",",
"dtype",
"=",
"None",
",",
"copy",
"=",
"False",
")",
":",
"subarr",
"=",
"np",
".",
"array",
"(",
"values",
",",
"dtype",
"=",
"dtype",
",",
"copy",
"=",
"copy",
")",
"if",
"dtype",
"is"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | maybe_cast_to_integer_array | Takes any dtype and returns the casted version, raising for when data is
incompatible with integer/unsigned integer dtypes.
.. versionadded:: 0.24.0
Parameters
----------
arr : array-like
The array to cast.
dtype : str, np.dtype
The integer dtype to cast the array to.
copy:... | pandas/core/dtypes/cast.py | def maybe_cast_to_integer_array(arr, dtype, copy=False):
"""
Takes any dtype and returns the casted version, raising for when data is
incompatible with integer/unsigned integer dtypes.
.. versionadded:: 0.24.0
Parameters
----------
arr : array-like
The array to cast.
dtype : st... | def maybe_cast_to_integer_array(arr, dtype, copy=False):
"""
Takes any dtype and returns the casted version, raising for when data is
incompatible with integer/unsigned integer dtypes.
.. versionadded:: 0.24.0
Parameters
----------
arr : array-like
The array to cast.
dtype : st... | [
"Takes",
"any",
"dtype",
"and",
"returns",
"the",
"casted",
"version",
"raising",
"for",
"when",
"data",
"is",
"incompatible",
"with",
"integer",
"/",
"unsigned",
"integer",
"dtypes",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L1269-L1337 | [
"def",
"maybe_cast_to_integer_array",
"(",
"arr",
",",
"dtype",
",",
"copy",
"=",
"False",
")",
":",
"try",
":",
"if",
"not",
"hasattr",
"(",
"arr",
",",
"\"astype\"",
")",
":",
"casted",
"=",
"np",
".",
"array",
"(",
"arr",
",",
"dtype",
"=",
"dtype... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | scatter_plot | Make a scatter plot from two DataFrame columns
Parameters
----------
data : DataFrame
x : Column name for the x-axis values
y : Column name for the y-axis values
ax : Matplotlib axis object
figsize : A tuple (width, height) in inches
grid : Setting this to True will show the grid
kw... | pandas/plotting/_core.py | def scatter_plot(data, x, y, by=None, ax=None, figsize=None, grid=False,
**kwargs):
"""
Make a scatter plot from two DataFrame columns
Parameters
----------
data : DataFrame
x : Column name for the x-axis values
y : Column name for the y-axis values
ax : Matplotlib axis... | def scatter_plot(data, x, y, by=None, ax=None, figsize=None, grid=False,
**kwargs):
"""
Make a scatter plot from two DataFrame columns
Parameters
----------
data : DataFrame
x : Column name for the x-axis values
y : Column name for the y-axis values
ax : Matplotlib axis... | [
"Make",
"a",
"scatter",
"plot",
"from",
"two",
"DataFrame",
"columns"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L2284-L2328 | [
"def",
"scatter_plot",
"(",
"data",
",",
"x",
",",
"y",
",",
"by",
"=",
"None",
",",
"ax",
"=",
"None",
",",
"figsize",
"=",
"None",
",",
"grid",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | hist_frame | Make a histogram of the DataFrame's.
A `histogram`_ is a representation of the distribution of data.
This function calls :meth:`matplotlib.pyplot.hist`, on each series in
the DataFrame, resulting in one histogram per column.
.. _histogram: https://en.wikipedia.org/wiki/Histogram
Parameters
--... | pandas/plotting/_core.py | def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None,
xrot=None, ylabelsize=None, yrot=None, ax=None, sharex=False,
sharey=False, figsize=None, layout=None, bins=10, **kwds):
"""
Make a histogram of the DataFrame's.
A `histogram`_ is a representation of the di... | def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None,
xrot=None, ylabelsize=None, yrot=None, ax=None, sharex=False,
sharey=False, figsize=None, layout=None, bins=10, **kwds):
"""
Make a histogram of the DataFrame's.
A `histogram`_ is a representation of the di... | [
"Make",
"a",
"histogram",
"of",
"the",
"DataFrame",
"s",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L2331-L2443 | [
"def",
"hist_frame",
"(",
"data",
",",
"column",
"=",
"None",
",",
"by",
"=",
"None",
",",
"grid",
"=",
"True",
",",
"xlabelsize",
"=",
"None",
",",
"xrot",
"=",
"None",
",",
"ylabelsize",
"=",
"None",
",",
"yrot",
"=",
"None",
",",
"ax",
"=",
"N... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | hist_series | Draw histogram of the input series using matplotlib.
Parameters
----------
by : object, optional
If passed, then used to form histograms for separate groups
ax : matplotlib axis object
If not passed, uses gca()
grid : bool, default True
Whether to show axis grid lines
xl... | pandas/plotting/_core.py | def hist_series(self, by=None, ax=None, grid=True, xlabelsize=None,
xrot=None, ylabelsize=None, yrot=None, figsize=None,
bins=10, **kwds):
"""
Draw histogram of the input series using matplotlib.
Parameters
----------
by : object, optional
If passed, then use... | def hist_series(self, by=None, ax=None, grid=True, xlabelsize=None,
xrot=None, ylabelsize=None, yrot=None, figsize=None,
bins=10, **kwds):
"""
Draw histogram of the input series using matplotlib.
Parameters
----------
by : object, optional
If passed, then use... | [
"Draw",
"histogram",
"of",
"the",
"input",
"series",
"using",
"matplotlib",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L2446-L2521 | [
"def",
"hist_series",
"(",
"self",
",",
"by",
"=",
"None",
",",
"ax",
"=",
"None",
",",
"grid",
"=",
"True",
",",
"xlabelsize",
"=",
"None",
",",
"xrot",
"=",
"None",
",",
"ylabelsize",
"=",
"None",
",",
"yrot",
"=",
"None",
",",
"figsize",
"=",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | grouped_hist | Grouped histogram
Parameters
----------
data : Series/DataFrame
column : object, optional
by : object, optional
ax : axes, optional
bins : int, default 50
figsize : tuple, optional
layout : optional
sharex : bool, default False
sharey : bool, default False
rot : int, def... | pandas/plotting/_core.py | def grouped_hist(data, column=None, by=None, ax=None, bins=50, figsize=None,
layout=None, sharex=False, sharey=False, rot=90, grid=True,
xlabelsize=None, xrot=None, ylabelsize=None, yrot=None,
**kwargs):
"""
Grouped histogram
Parameters
----------
... | def grouped_hist(data, column=None, by=None, ax=None, bins=50, figsize=None,
layout=None, sharex=False, sharey=False, rot=90, grid=True,
xlabelsize=None, xrot=None, ylabelsize=None, yrot=None,
**kwargs):
"""
Grouped histogram
Parameters
----------
... | [
"Grouped",
"histogram"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L2524-L2567 | [
"def",
"grouped_hist",
"(",
"data",
",",
"column",
"=",
"None",
",",
"by",
"=",
"None",
",",
"ax",
"=",
"None",
",",
"bins",
"=",
"50",
",",
"figsize",
"=",
"None",
",",
"layout",
"=",
"None",
",",
"sharex",
"=",
"False",
",",
"sharey",
"=",
"Fal... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | boxplot_frame_groupby | Make box plots from DataFrameGroupBy data.
Parameters
----------
grouped : Grouped DataFrame
subplots : bool
* ``False`` - no subplots will be used
* ``True`` - create a subplot for each group
column : column name or list of names, or vector
Can be any valid input to groupby... | pandas/plotting/_core.py | def boxplot_frame_groupby(grouped, subplots=True, column=None, fontsize=None,
rot=0, grid=True, ax=None, figsize=None,
layout=None, sharex=False, sharey=True, **kwds):
"""
Make box plots from DataFrameGroupBy data.
Parameters
----------
grouped : ... | def boxplot_frame_groupby(grouped, subplots=True, column=None, fontsize=None,
rot=0, grid=True, ax=None, figsize=None,
layout=None, sharex=False, sharey=True, **kwds):
"""
Make box plots from DataFrameGroupBy data.
Parameters
----------
grouped : ... | [
"Make",
"box",
"plots",
"from",
"DataFrameGroupBy",
"data",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L2570-L2653 | [
"def",
"boxplot_frame_groupby",
"(",
"grouped",
",",
"subplots",
"=",
"True",
",",
"column",
"=",
"None",
",",
"fontsize",
"=",
"None",
",",
"rot",
"=",
"0",
",",
"grid",
"=",
"True",
",",
"ax",
"=",
"None",
",",
"figsize",
"=",
"None",
",",
"layout"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.