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 | array | Create an array.
.. versionadded:: 0.24.0
Parameters
----------
data : Sequence of objects
The scalars inside `data` should be instances of the
scalar type for `dtype`. It's expected that `data`
represents a 1-dimensional array of data.
When `data` is an Index or Serie... | pandas/core/arrays/array_.py | def array(data: Sequence[object],
dtype: Optional[Union[str, np.dtype, ExtensionDtype]] = None,
copy: bool = True,
) -> ABCExtensionArray:
"""
Create an array.
.. versionadded:: 0.24.0
Parameters
----------
data : Sequence of objects
The scalars inside `da... | def array(data: Sequence[object],
dtype: Optional[Union[str, np.dtype, ExtensionDtype]] = None,
copy: bool = True,
) -> ABCExtensionArray:
"""
Create an array.
.. versionadded:: 0.24.0
Parameters
----------
data : Sequence of objects
The scalars inside `da... | [
"Create",
"an",
"array",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/array_.py#L13-L276 | [
"def",
"array",
"(",
"data",
":",
"Sequence",
"[",
"object",
"]",
",",
"dtype",
":",
"Optional",
"[",
"Union",
"[",
"str",
",",
"np",
".",
"dtype",
",",
"ExtensionDtype",
"]",
"]",
"=",
"None",
",",
"copy",
":",
"bool",
"=",
"True",
",",
")",
"->... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | maybe_convert_platform_interval | Try to do platform conversion, with special casing for IntervalArray.
Wrapper around maybe_convert_platform that alters the default return
dtype in certain cases to be compatible with IntervalArray. For example,
empty lists return with integer dtype instead of object dtype, which is
prohibited for Inte... | pandas/core/arrays/interval.py | def maybe_convert_platform_interval(values):
"""
Try to do platform conversion, with special casing for IntervalArray.
Wrapper around maybe_convert_platform that alters the default return
dtype in certain cases to be compatible with IntervalArray. For example,
empty lists return with integer dtype ... | def maybe_convert_platform_interval(values):
"""
Try to do platform conversion, with special casing for IntervalArray.
Wrapper around maybe_convert_platform that alters the default return
dtype in certain cases to be compatible with IntervalArray. For example,
empty lists return with integer dtype ... | [
"Try",
"to",
"do",
"platform",
"conversion",
"with",
"special",
"casing",
"for",
"IntervalArray",
".",
"Wrapper",
"around",
"maybe_convert_platform",
"that",
"alters",
"the",
"default",
"return",
"dtype",
"in",
"certain",
"cases",
"to",
"be",
"compatible",
"with",... | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/interval.py#L1078-L1102 | [
"def",
"maybe_convert_platform_interval",
"(",
"values",
")",
":",
"if",
"isinstance",
"(",
"values",
",",
"(",
"list",
",",
"tuple",
")",
")",
"and",
"len",
"(",
"values",
")",
"==",
"0",
":",
"# GH 19016",
"# empty lists/tuples get object dtype by default, but t... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | is_file_like | Check if the object is a file-like object.
For objects to be considered file-like, they must
be an iterator AND have either a `read` and/or `write`
method as an attribute.
Note: file-like objects must be iterable, but
iterable objects need not be file-like.
.. versionadded:: 0.20.0
Param... | pandas/core/dtypes/inference.py | def is_file_like(obj):
"""
Check if the object is a file-like object.
For objects to be considered file-like, they must
be an iterator AND have either a `read` and/or `write`
method as an attribute.
Note: file-like objects must be iterable, but
iterable objects need not be file-like.
... | def is_file_like(obj):
"""
Check if the object is a file-like object.
For objects to be considered file-like, they must
be an iterator AND have either a `read` and/or `write`
method as an attribute.
Note: file-like objects must be iterable, but
iterable objects need not be file-like.
... | [
"Check",
"if",
"the",
"object",
"is",
"a",
"file",
"-",
"like",
"object",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/inference.py#L152-L189 | [
"def",
"is_file_like",
"(",
"obj",
")",
":",
"if",
"not",
"(",
"hasattr",
"(",
"obj",
",",
"'read'",
")",
"or",
"hasattr",
"(",
"obj",
",",
"'write'",
")",
")",
":",
"return",
"False",
"if",
"not",
"hasattr",
"(",
"obj",
",",
"\"__iter__\"",
")",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | is_list_like | Check if the object is list-like.
Objects that are considered list-like are for example Python
lists, tuples, sets, NumPy arrays, and Pandas Series.
Strings and datetime objects, however, are not considered list-like.
Parameters
----------
obj : The object to check
allow_sets : boolean, d... | pandas/core/dtypes/inference.py | def is_list_like(obj, allow_sets=True):
"""
Check if the object is list-like.
Objects that are considered list-like are for example Python
lists, tuples, sets, NumPy arrays, and Pandas Series.
Strings and datetime objects, however, are not considered list-like.
Parameters
----------
o... | def is_list_like(obj, allow_sets=True):
"""
Check if the object is list-like.
Objects that are considered list-like are for example Python
lists, tuples, sets, NumPy arrays, and Pandas Series.
Strings and datetime objects, however, are not considered list-like.
Parameters
----------
o... | [
"Check",
"if",
"the",
"object",
"is",
"list",
"-",
"like",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/inference.py#L245-L293 | [
"def",
"is_list_like",
"(",
"obj",
",",
"allow_sets",
"=",
"True",
")",
":",
"return",
"(",
"isinstance",
"(",
"obj",
",",
"abc",
".",
"Iterable",
")",
"and",
"# we do not count strings/unicode/bytes as list-like",
"not",
"isinstance",
"(",
"obj",
",",
"(",
"s... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | is_nested_list_like | Check if the object is list-like, and that all of its elements
are also list-like.
.. versionadded:: 0.20.0
Parameters
----------
obj : The object to check
Returns
-------
is_list_like : bool
Whether `obj` has list-like properties.
Examples
--------
>>> is_nested_... | pandas/core/dtypes/inference.py | def is_nested_list_like(obj):
"""
Check if the object is list-like, and that all of its elements
are also list-like.
.. versionadded:: 0.20.0
Parameters
----------
obj : The object to check
Returns
-------
is_list_like : bool
Whether `obj` has list-like properties.
... | def is_nested_list_like(obj):
"""
Check if the object is list-like, and that all of its elements
are also list-like.
.. versionadded:: 0.20.0
Parameters
----------
obj : The object to check
Returns
-------
is_list_like : bool
Whether `obj` has list-like properties.
... | [
"Check",
"if",
"the",
"object",
"is",
"list",
"-",
"like",
"and",
"that",
"all",
"of",
"its",
"elements",
"are",
"also",
"list",
"-",
"like",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/inference.py#L329-L370 | [
"def",
"is_nested_list_like",
"(",
"obj",
")",
":",
"return",
"(",
"is_list_like",
"(",
"obj",
")",
"and",
"hasattr",
"(",
"obj",
",",
"'__len__'",
")",
"and",
"len",
"(",
"obj",
")",
">",
"0",
"and",
"all",
"(",
"is_list_like",
"(",
"item",
")",
"fo... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | is_dict_like | Check if the object is dict-like.
Parameters
----------
obj : The object to check
Returns
-------
is_dict_like : bool
Whether `obj` has dict-like properties.
Examples
--------
>>> is_dict_like({1: 2})
True
>>> is_dict_like([1, 2, 3])
False
>>> is_dict_like(... | pandas/core/dtypes/inference.py | def is_dict_like(obj):
"""
Check if the object is dict-like.
Parameters
----------
obj : The object to check
Returns
-------
is_dict_like : bool
Whether `obj` has dict-like properties.
Examples
--------
>>> is_dict_like({1: 2})
True
>>> is_dict_like([1, 2, ... | def is_dict_like(obj):
"""
Check if the object is dict-like.
Parameters
----------
obj : The object to check
Returns
-------
is_dict_like : bool
Whether `obj` has dict-like properties.
Examples
--------
>>> is_dict_like({1: 2})
True
>>> is_dict_like([1, 2, ... | [
"Check",
"if",
"the",
"object",
"is",
"dict",
"-",
"like",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/inference.py#L373-L400 | [
"def",
"is_dict_like",
"(",
"obj",
")",
":",
"dict_like_attrs",
"=",
"(",
"\"__getitem__\"",
",",
"\"keys\"",
",",
"\"__contains__\"",
")",
"return",
"(",
"all",
"(",
"hasattr",
"(",
"obj",
",",
"attr",
")",
"for",
"attr",
"in",
"dict_like_attrs",
")",
"# ... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | is_sequence | Check if the object is a sequence of objects.
String types are not included as sequences here.
Parameters
----------
obj : The object to check
Returns
-------
is_sequence : bool
Whether `obj` is a sequence of objects.
Examples
--------
>>> l = [1, 2, 3]
>>>
>>>... | pandas/core/dtypes/inference.py | def is_sequence(obj):
"""
Check if the object is a sequence of objects.
String types are not included as sequences here.
Parameters
----------
obj : The object to check
Returns
-------
is_sequence : bool
Whether `obj` is a sequence of objects.
Examples
--------
... | def is_sequence(obj):
"""
Check if the object is a sequence of objects.
String types are not included as sequences here.
Parameters
----------
obj : The object to check
Returns
-------
is_sequence : bool
Whether `obj` is a sequence of objects.
Examples
--------
... | [
"Check",
"if",
"the",
"object",
"is",
"a",
"sequence",
"of",
"objects",
".",
"String",
"types",
"are",
"not",
"included",
"as",
"sequences",
"here",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/inference.py#L462-L491 | [
"def",
"is_sequence",
"(",
"obj",
")",
":",
"try",
":",
"iter",
"(",
"obj",
")",
"# Can iterate over it.",
"len",
"(",
"obj",
")",
"# Has a length associated with it.",
"return",
"not",
"isinstance",
"(",
"obj",
",",
"(",
"str",
",",
"bytes",
")",
")",
"ex... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _new_DatetimeIndex | This is called upon unpickling, rather than the default which doesn't
have arguments and breaks __new__ | pandas/core/indexes/datetimes.py | def _new_DatetimeIndex(cls, d):
""" This is called upon unpickling, rather than the default which doesn't
have arguments and breaks __new__ """
if "data" in d and not isinstance(d["data"], DatetimeIndex):
# Avoid need to verify integrity by calling simple_new directly
data = d.pop("data")
... | def _new_DatetimeIndex(cls, d):
""" This is called upon unpickling, rather than the default which doesn't
have arguments and breaks __new__ """
if "data" in d and not isinstance(d["data"], DatetimeIndex):
# Avoid need to verify integrity by calling simple_new directly
data = d.pop("data")
... | [
"This",
"is",
"called",
"upon",
"unpickling",
"rather",
"than",
"the",
"default",
"which",
"doesn",
"t",
"have",
"arguments",
"and",
"breaks",
"__new__"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/datetimes.py#L35-L51 | [
"def",
"_new_DatetimeIndex",
"(",
"cls",
",",
"d",
")",
":",
"if",
"\"data\"",
"in",
"d",
"and",
"not",
"isinstance",
"(",
"d",
"[",
"\"data\"",
"]",
",",
"DatetimeIndex",
")",
":",
"# Avoid need to verify integrity by calling simple_new directly",
"data",
"=",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | date_range | Return a fixed frequency DatetimeIndex.
Parameters
----------
start : str or datetime-like, optional
Left bound for generating dates.
end : str or datetime-like, optional
Right bound for generating dates.
periods : integer, optional
Number of periods to generate.
freq : ... | pandas/core/indexes/datetimes.py | def date_range(start=None, end=None, periods=None, freq=None, tz=None,
normalize=False, name=None, closed=None, **kwargs):
"""
Return a fixed frequency DatetimeIndex.
Parameters
----------
start : str or datetime-like, optional
Left bound for generating dates.
end : str o... | def date_range(start=None, end=None, periods=None, freq=None, tz=None,
normalize=False, name=None, closed=None, **kwargs):
"""
Return a fixed frequency DatetimeIndex.
Parameters
----------
start : str or datetime-like, optional
Left bound for generating dates.
end : str o... | [
"Return",
"a",
"fixed",
"frequency",
"DatetimeIndex",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/datetimes.py#L1398-L1545 | [
"def",
"date_range",
"(",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"periods",
"=",
"None",
",",
"freq",
"=",
"None",
",",
"tz",
"=",
"None",
",",
"normalize",
"=",
"False",
",",
"name",
"=",
"None",
",",
"closed",
"=",
"None",
",",
"*"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | bdate_range | Return a fixed frequency DatetimeIndex, with business day as the default
frequency
Parameters
----------
start : string or datetime-like, default None
Left bound for generating dates.
end : string or datetime-like, default None
Right bound for generating dates.
periods : integer... | pandas/core/indexes/datetimes.py | def bdate_range(start=None, end=None, periods=None, freq='B', tz=None,
normalize=True, name=None, weekmask=None, holidays=None,
closed=None, **kwargs):
"""
Return a fixed frequency DatetimeIndex, with business day as the default
frequency
Parameters
----------
st... | def bdate_range(start=None, end=None, periods=None, freq='B', tz=None,
normalize=True, name=None, weekmask=None, holidays=None,
closed=None, **kwargs):
"""
Return a fixed frequency DatetimeIndex, with business day as the default
frequency
Parameters
----------
st... | [
"Return",
"a",
"fixed",
"frequency",
"DatetimeIndex",
"with",
"business",
"day",
"as",
"the",
"default",
"frequency"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/datetimes.py#L1548-L1633 | [
"def",
"bdate_range",
"(",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"periods",
"=",
"None",
",",
"freq",
"=",
"'B'",
",",
"tz",
"=",
"None",
",",
"normalize",
"=",
"True",
",",
"name",
"=",
"None",
",",
"weekmask",
"=",
"None",
",",
"h... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | cdate_range | Return a fixed frequency DatetimeIndex, with CustomBusinessDay as the
default frequency
.. deprecated:: 0.21.0
Parameters
----------
start : string or datetime-like, default None
Left bound for generating dates
end : string or datetime-like, default None
Right bound for generat... | pandas/core/indexes/datetimes.py | def cdate_range(start=None, end=None, periods=None, freq='C', tz=None,
normalize=True, name=None, closed=None, **kwargs):
"""
Return a fixed frequency DatetimeIndex, with CustomBusinessDay as the
default frequency
.. deprecated:: 0.21.0
Parameters
----------
start : string ... | def cdate_range(start=None, end=None, periods=None, freq='C', tz=None,
normalize=True, name=None, closed=None, **kwargs):
"""
Return a fixed frequency DatetimeIndex, with CustomBusinessDay as the
default frequency
.. deprecated:: 0.21.0
Parameters
----------
start : string ... | [
"Return",
"a",
"fixed",
"frequency",
"DatetimeIndex",
"with",
"CustomBusinessDay",
"as",
"the",
"default",
"frequency"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/datetimes.py#L1636-L1693 | [
"def",
"cdate_range",
"(",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"periods",
"=",
"None",
",",
"freq",
"=",
"'C'",
",",
"tz",
"=",
"None",
",",
"normalize",
"=",
"True",
",",
"name",
"=",
"None",
",",
"closed",
"=",
"None",
",",
"*",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _Window._create_blocks | Split data into blocks & return conformed data. | pandas/core/window.py | def _create_blocks(self):
"""
Split data into blocks & return conformed data.
"""
obj, index = self._convert_freq()
if index is not None:
index = self._on
# filter out the on from the object
if self.on is not None:
if obj.ndim == 2:
... | def _create_blocks(self):
"""
Split data into blocks & return conformed data.
"""
obj, index = self._convert_freq()
if index is not None:
index = self._on
# filter out the on from the object
if self.on is not None:
if obj.ndim == 2:
... | [
"Split",
"data",
"into",
"blocks",
"&",
"return",
"conformed",
"data",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L99-L115 | [
"def",
"_create_blocks",
"(",
"self",
")",
":",
"obj",
",",
"index",
"=",
"self",
".",
"_convert_freq",
"(",
")",
"if",
"index",
"is",
"not",
"None",
":",
"index",
"=",
"self",
".",
"_on",
"# filter out the on from the object",
"if",
"self",
".",
"on",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _Window._gotitem | Sub-classes to define. Return a sliced object.
Parameters
----------
key : str / list of selections
ndim : 1,2
requested ndim of result
subset : object, default None
subset to act on | pandas/core/window.py | def _gotitem(self, key, ndim, subset=None):
"""
Sub-classes to define. Return a sliced object.
Parameters
----------
key : str / list of selections
ndim : 1,2
requested ndim of result
subset : object, default None
subset to act on
... | def _gotitem(self, key, ndim, subset=None):
"""
Sub-classes to define. Return a sliced object.
Parameters
----------
key : str / list of selections
ndim : 1,2
requested ndim of result
subset : object, default None
subset to act on
... | [
"Sub",
"-",
"classes",
"to",
"define",
".",
"Return",
"a",
"sliced",
"object",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L117-L138 | [
"def",
"_gotitem",
"(",
"self",
",",
"key",
",",
"ndim",
",",
"subset",
"=",
"None",
")",
":",
"# create a new object to prevent aliasing",
"if",
"subset",
"is",
"None",
":",
"subset",
"=",
"self",
".",
"obj",
"self",
"=",
"self",
".",
"_shallow_copy",
"("... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _Window._get_index | Return index as ndarrays.
Returns
-------
tuple of (index, index_as_ndarray) | pandas/core/window.py | def _get_index(self, index=None):
"""
Return index as ndarrays.
Returns
-------
tuple of (index, index_as_ndarray)
"""
if self.is_freq_type:
if index is None:
index = self._on
return index, index.asi8
return index,... | def _get_index(self, index=None):
"""
Return index as ndarrays.
Returns
-------
tuple of (index, index_as_ndarray)
"""
if self.is_freq_type:
if index is None:
index = self._on
return index, index.asi8
return index,... | [
"Return",
"index",
"as",
"ndarrays",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L174-L187 | [
"def",
"_get_index",
"(",
"self",
",",
"index",
"=",
"None",
")",
":",
"if",
"self",
".",
"is_freq_type",
":",
"if",
"index",
"is",
"None",
":",
"index",
"=",
"self",
".",
"_on",
"return",
"index",
",",
"index",
".",
"asi8",
"return",
"index",
",",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _Window._wrap_result | Wrap a single result. | pandas/core/window.py | def _wrap_result(self, result, block=None, obj=None):
"""
Wrap a single result.
"""
if obj is None:
obj = self._selected_obj
index = obj.index
if isinstance(result, np.ndarray):
# coerce if necessary
if block is not None:
... | def _wrap_result(self, result, block=None, obj=None):
"""
Wrap a single result.
"""
if obj is None:
obj = self._selected_obj
index = obj.index
if isinstance(result, np.ndarray):
# coerce if necessary
if block is not None:
... | [
"Wrap",
"a",
"single",
"result",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L219-L242 | [
"def",
"_wrap_result",
"(",
"self",
",",
"result",
",",
"block",
"=",
"None",
",",
"obj",
"=",
"None",
")",
":",
"if",
"obj",
"is",
"None",
":",
"obj",
"=",
"self",
".",
"_selected_obj",
"index",
"=",
"obj",
".",
"index",
"if",
"isinstance",
"(",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _Window._wrap_results | Wrap the results.
Parameters
----------
results : list of ndarrays
blocks : list of blocks
obj : conformed data (may be resampled) | pandas/core/window.py | def _wrap_results(self, results, blocks, obj):
"""
Wrap the results.
Parameters
----------
results : list of ndarrays
blocks : list of blocks
obj : conformed data (may be resampled)
"""
from pandas import Series, concat
from pandas.core.i... | def _wrap_results(self, results, blocks, obj):
"""
Wrap the results.
Parameters
----------
results : list of ndarrays
blocks : list of blocks
obj : conformed data (may be resampled)
"""
from pandas import Series, concat
from pandas.core.i... | [
"Wrap",
"the",
"results",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L244-L288 | [
"def",
"_wrap_results",
"(",
"self",
",",
"results",
",",
"blocks",
",",
"obj",
")",
":",
"from",
"pandas",
"import",
"Series",
",",
"concat",
"from",
"pandas",
".",
"core",
".",
"index",
"import",
"ensure_index",
"final",
"=",
"[",
"]",
"for",
"result",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _Window._center_window | Center the result in the window. | pandas/core/window.py | def _center_window(self, result, window):
"""
Center the result in the window.
"""
if self.axis > result.ndim - 1:
raise ValueError("Requested axis is larger then no. of argument "
"dimensions")
offset = _offset(window, True)
if o... | def _center_window(self, result, window):
"""
Center the result in the window.
"""
if self.axis > result.ndim - 1:
raise ValueError("Requested axis is larger then no. of argument "
"dimensions")
offset = _offset(window, True)
if o... | [
"Center",
"the",
"result",
"in",
"the",
"window",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L290-L306 | [
"def",
"_center_window",
"(",
"self",
",",
"result",
",",
"window",
")",
":",
"if",
"self",
".",
"axis",
">",
"result",
".",
"ndim",
"-",
"1",
":",
"raise",
"ValueError",
"(",
"\"Requested axis is larger then no. of argument \"",
"\"dimensions\"",
")",
"offset",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Window._prep_window | Provide validation for our window type, return the window
we have already been validated. | pandas/core/window.py | def _prep_window(self, **kwargs):
"""
Provide validation for our window type, return the window
we have already been validated.
"""
window = self._get_window()
if isinstance(window, (list, tuple, np.ndarray)):
return com.asarray_tuplesafe(window).astype(float... | def _prep_window(self, **kwargs):
"""
Provide validation for our window type, return the window
we have already been validated.
"""
window = self._get_window()
if isinstance(window, (list, tuple, np.ndarray)):
return com.asarray_tuplesafe(window).astype(float... | [
"Provide",
"validation",
"for",
"our",
"window",
"type",
"return",
"the",
"window",
"we",
"have",
"already",
"been",
"validated",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L609-L644 | [
"def",
"_prep_window",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"window",
"=",
"self",
".",
"_get_window",
"(",
")",
"if",
"isinstance",
"(",
"window",
",",
"(",
"list",
",",
"tuple",
",",
"np",
".",
"ndarray",
")",
")",
":",
"return",
"com"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Window._apply_window | Applies a moving window of type ``window_type`` on the data.
Parameters
----------
mean : bool, default True
If True computes weighted mean, else weighted sum
Returns
-------
y : same type as input argument | pandas/core/window.py | def _apply_window(self, mean=True, **kwargs):
"""
Applies a moving window of type ``window_type`` on the data.
Parameters
----------
mean : bool, default True
If True computes weighted mean, else weighted sum
Returns
-------
y : same type as ... | def _apply_window(self, mean=True, **kwargs):
"""
Applies a moving window of type ``window_type`` on the data.
Parameters
----------
mean : bool, default True
If True computes weighted mean, else weighted sum
Returns
-------
y : same type as ... | [
"Applies",
"a",
"moving",
"window",
"of",
"type",
"window_type",
"on",
"the",
"data",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L646-L692 | [
"def",
"_apply_window",
"(",
"self",
",",
"mean",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"window",
"=",
"self",
".",
"_prep_window",
"(",
"*",
"*",
"kwargs",
")",
"center",
"=",
"self",
".",
"center",
"blocks",
",",
"obj",
",",
"index",
"=... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _GroupByMixin._apply | Dispatch to apply; we are stripping all of the _apply kwargs and
performing the original function call on the grouped object. | pandas/core/window.py | def _apply(self, func, name, window=None, center=None,
check_minp=None, **kwargs):
"""
Dispatch to apply; we are stripping all of the _apply kwargs and
performing the original function call on the grouped object.
"""
def f(x, name=name, *args):
x = sel... | def _apply(self, func, name, window=None, center=None,
check_minp=None, **kwargs):
"""
Dispatch to apply; we are stripping all of the _apply kwargs and
performing the original function call on the grouped object.
"""
def f(x, name=name, *args):
x = sel... | [
"Dispatch",
"to",
"apply",
";",
"we",
"are",
"stripping",
"all",
"of",
"the",
"_apply",
"kwargs",
"and",
"performing",
"the",
"original",
"function",
"call",
"on",
"the",
"grouped",
"object",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L782-L797 | [
"def",
"_apply",
"(",
"self",
",",
"func",
",",
"name",
",",
"window",
"=",
"None",
",",
"center",
"=",
"None",
",",
"check_minp",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"f",
"(",
"x",
",",
"name",
"=",
"name",
",",
"*",
"args",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _Rolling._apply | Rolling statistical measure using supplied function.
Designed to be used with passed-in Cython array-based functions.
Parameters
----------
func : str/callable to apply
name : str, optional
name of this function
window : int/array, default to _get_window()
... | pandas/core/window.py | def _apply(self, func, name=None, window=None, center=None,
check_minp=None, **kwargs):
"""
Rolling statistical measure using supplied function.
Designed to be used with passed-in Cython array-based functions.
Parameters
----------
func : str/callable to ... | def _apply(self, func, name=None, window=None, center=None,
check_minp=None, **kwargs):
"""
Rolling statistical measure using supplied function.
Designed to be used with passed-in Cython array-based functions.
Parameters
----------
func : str/callable to ... | [
"Rolling",
"statistical",
"measure",
"using",
"supplied",
"function",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L806-L884 | [
"def",
"_apply",
"(",
"self",
",",
"func",
",",
"name",
"=",
"None",
",",
"window",
"=",
"None",
",",
"center",
"=",
"None",
",",
"check_minp",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"center",
"is",
"None",
":",
"center",
"=",
"sel... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Rolling._validate_monotonic | Validate on is_monotonic. | pandas/core/window.py | def _validate_monotonic(self):
"""
Validate on is_monotonic.
"""
if not self._on.is_monotonic:
formatted = self.on or 'index'
raise ValueError("{0} must be "
"monotonic".format(formatted)) | def _validate_monotonic(self):
"""
Validate on is_monotonic.
"""
if not self._on.is_monotonic:
formatted = self.on or 'index'
raise ValueError("{0} must be "
"monotonic".format(formatted)) | [
"Validate",
"on",
"is_monotonic",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L1602-L1609 | [
"def",
"_validate_monotonic",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_on",
".",
"is_monotonic",
":",
"formatted",
"=",
"self",
".",
"on",
"or",
"'index'",
"raise",
"ValueError",
"(",
"\"{0} must be \"",
"\"monotonic\"",
".",
"format",
"(",
"format... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Rolling._validate_freq | Validate & return window frequency. | pandas/core/window.py | def _validate_freq(self):
"""
Validate & return window frequency.
"""
from pandas.tseries.frequencies import to_offset
try:
return to_offset(self.window)
except (TypeError, ValueError):
raise ValueError("passed window {0} is not "
... | def _validate_freq(self):
"""
Validate & return window frequency.
"""
from pandas.tseries.frequencies import to_offset
try:
return to_offset(self.window)
except (TypeError, ValueError):
raise ValueError("passed window {0} is not "
... | [
"Validate",
"&",
"return",
"window",
"frequency",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L1611-L1621 | [
"def",
"_validate_freq",
"(",
"self",
")",
":",
"from",
"pandas",
".",
"tseries",
".",
"frequencies",
"import",
"to_offset",
"try",
":",
"return",
"to_offset",
"(",
"self",
".",
"window",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
"raise... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Expanding._get_window | Get the window length over which to perform some operation.
Parameters
----------
other : object, default None
The other object that is involved in the operation.
Such an object is involved for operations like covariance.
Returns
-------
window :... | pandas/core/window.py | def _get_window(self, other=None):
"""
Get the window length over which to perform some operation.
Parameters
----------
other : object, default None
The other object that is involved in the operation.
Such an object is involved for operations like covari... | def _get_window(self, other=None):
"""
Get the window length over which to perform some operation.
Parameters
----------
other : object, default None
The other object that is involved in the operation.
Such an object is involved for operations like covari... | [
"Get",
"the",
"window",
"length",
"over",
"which",
"to",
"perform",
"some",
"operation",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L1888-L1907 | [
"def",
"_get_window",
"(",
"self",
",",
"other",
"=",
"None",
")",
":",
"axis",
"=",
"self",
".",
"obj",
".",
"_get_axis",
"(",
"self",
".",
"axis",
")",
"length",
"=",
"len",
"(",
"axis",
")",
"+",
"(",
"other",
"is",
"not",
"None",
")",
"*",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | EWM._apply | Rolling statistical measure using supplied function. Designed to be
used with passed-in Cython array-based functions.
Parameters
----------
func : str/callable to apply
Returns
-------
y : same type as input argument | pandas/core/window.py | def _apply(self, func, **kwargs):
"""
Rolling statistical measure using supplied function. Designed to be
used with passed-in Cython array-based functions.
Parameters
----------
func : str/callable to apply
Returns
-------
y : same type as input ... | def _apply(self, func, **kwargs):
"""
Rolling statistical measure using supplied function. Designed to be
used with passed-in Cython array-based functions.
Parameters
----------
func : str/callable to apply
Returns
-------
y : same type as input ... | [
"Rolling",
"statistical",
"measure",
"using",
"supplied",
"function",
".",
"Designed",
"to",
"be",
"used",
"with",
"passed",
"-",
"in",
"Cython",
"array",
"-",
"based",
"functions",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L2269-L2308 | [
"def",
"_apply",
"(",
"self",
",",
"func",
",",
"*",
"*",
"kwargs",
")",
":",
"blocks",
",",
"obj",
",",
"index",
"=",
"self",
".",
"_create_blocks",
"(",
")",
"results",
"=",
"[",
"]",
"for",
"b",
"in",
"blocks",
":",
"try",
":",
"values",
"=",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | EWM.mean | Exponential weighted moving average.
Parameters
----------
*args, **kwargs
Arguments and keyword arguments to be passed into func. | pandas/core/window.py | def mean(self, *args, **kwargs):
"""
Exponential weighted moving average.
Parameters
----------
*args, **kwargs
Arguments and keyword arguments to be passed into func.
"""
nv.validate_window_func('mean', args, kwargs)
return self._apply('ewma'... | def mean(self, *args, **kwargs):
"""
Exponential weighted moving average.
Parameters
----------
*args, **kwargs
Arguments and keyword arguments to be passed into func.
"""
nv.validate_window_func('mean', args, kwargs)
return self._apply('ewma'... | [
"Exponential",
"weighted",
"moving",
"average",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L2312-L2322 | [
"def",
"mean",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"nv",
".",
"validate_window_func",
"(",
"'mean'",
",",
"args",
",",
"kwargs",
")",
"return",
"self",
".",
"_apply",
"(",
"'ewma'",
",",
"*",
"*",
"kwargs",
")"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | EWM.std | Exponential weighted moving stddev. | pandas/core/window.py | def std(self, bias=False, *args, **kwargs):
"""
Exponential weighted moving stddev.
"""
nv.validate_window_func('std', args, kwargs)
return _zsqrt(self.var(bias=bias, **kwargs)) | def std(self, bias=False, *args, **kwargs):
"""
Exponential weighted moving stddev.
"""
nv.validate_window_func('std', args, kwargs)
return _zsqrt(self.var(bias=bias, **kwargs)) | [
"Exponential",
"weighted",
"moving",
"stddev",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L2327-L2332 | [
"def",
"std",
"(",
"self",
",",
"bias",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"nv",
".",
"validate_window_func",
"(",
"'std'",
",",
"args",
",",
"kwargs",
")",
"return",
"_zsqrt",
"(",
"self",
".",
"var",
"(",
"bias",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | EWM.var | Exponential weighted moving variance. | pandas/core/window.py | def var(self, bias=False, *args, **kwargs):
"""
Exponential weighted moving variance.
"""
nv.validate_window_func('var', args, kwargs)
def f(arg):
return libwindow.ewmcov(arg, arg, self.com, int(self.adjust),
int(self.ignore_na), i... | def var(self, bias=False, *args, **kwargs):
"""
Exponential weighted moving variance.
"""
nv.validate_window_func('var', args, kwargs)
def f(arg):
return libwindow.ewmcov(arg, arg, self.com, int(self.adjust),
int(self.ignore_na), i... | [
"Exponential",
"weighted",
"moving",
"variance",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L2339-L2350 | [
"def",
"var",
"(",
"self",
",",
"bias",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"nv",
".",
"validate_window_func",
"(",
"'var'",
",",
"args",
",",
"kwargs",
")",
"def",
"f",
"(",
"arg",
")",
":",
"return",
"libwindow",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | EWM.cov | Exponential weighted sample covariance. | pandas/core/window.py | def cov(self, other=None, pairwise=None, bias=False, **kwargs):
"""
Exponential weighted sample covariance.
"""
if other is None:
other = self._selected_obj
# only default unset
pairwise = True if pairwise is None else pairwise
other = self._sh... | def cov(self, other=None, pairwise=None, bias=False, **kwargs):
"""
Exponential weighted sample covariance.
"""
if other is None:
other = self._selected_obj
# only default unset
pairwise = True if pairwise is None else pairwise
other = self._sh... | [
"Exponential",
"weighted",
"sample",
"covariance",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L2355-L2375 | [
"def",
"cov",
"(",
"self",
",",
"other",
"=",
"None",
",",
"pairwise",
"=",
"None",
",",
"bias",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"other",
"is",
"None",
":",
"other",
"=",
"self",
".",
"_selected_obj",
"# only default unset",
"p... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | EWM.corr | Exponential weighted sample correlation. | pandas/core/window.py | def corr(self, other=None, pairwise=None, **kwargs):
"""
Exponential weighted sample correlation.
"""
if other is None:
other = self._selected_obj
# only default unset
pairwise = True if pairwise is None else pairwise
other = self._shallow_copy... | def corr(self, other=None, pairwise=None, **kwargs):
"""
Exponential weighted sample correlation.
"""
if other is None:
other = self._selected_obj
# only default unset
pairwise = True if pairwise is None else pairwise
other = self._shallow_copy... | [
"Exponential",
"weighted",
"sample",
"correlation",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L2380-L2410 | [
"def",
"corr",
"(",
"self",
",",
"other",
"=",
"None",
",",
"pairwise",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"other",
"is",
"None",
":",
"other",
"=",
"self",
".",
"_selected_obj",
"# only default unset",
"pairwise",
"=",
"True",
"if",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _ensure_like_indices | Makes sure that time and panels are conformable. | pandas/core/panel.py | def _ensure_like_indices(time, panels):
"""
Makes sure that time and panels are conformable.
"""
n_time = len(time)
n_panel = len(panels)
u_panels = np.unique(panels) # this sorts!
u_time = np.unique(time)
if len(u_time) == n_time:
time = np.tile(u_time, len(u_panels))
if le... | def _ensure_like_indices(time, panels):
"""
Makes sure that time and panels are conformable.
"""
n_time = len(time)
n_panel = len(panels)
u_panels = np.unique(panels) # this sorts!
u_time = np.unique(time)
if len(u_time) == n_time:
time = np.tile(u_time, len(u_panels))
if le... | [
"Makes",
"sure",
"that",
"time",
"and",
"panels",
"are",
"conformable",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L45-L57 | [
"def",
"_ensure_like_indices",
"(",
"time",
",",
"panels",
")",
":",
"n_time",
"=",
"len",
"(",
"time",
")",
"n_panel",
"=",
"len",
"(",
"panels",
")",
"u_panels",
"=",
"np",
".",
"unique",
"(",
"panels",
")",
"# this sorts!",
"u_time",
"=",
"np",
".",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | panel_index | Returns a multi-index suitable for a panel-like DataFrame.
Parameters
----------
time : array-like
Time index, does not have to repeat
panels : array-like
Panel index, does not have to repeat
names : list, optional
List containing the names of the indices
Returns
--... | pandas/core/panel.py | def panel_index(time, panels, names=None):
"""
Returns a multi-index suitable for a panel-like DataFrame.
Parameters
----------
time : array-like
Time index, does not have to repeat
panels : array-like
Panel index, does not have to repeat
names : list, optional
List ... | def panel_index(time, panels, names=None):
"""
Returns a multi-index suitable for a panel-like DataFrame.
Parameters
----------
time : array-like
Time index, does not have to repeat
panels : array-like
Panel index, does not have to repeat
names : list, optional
List ... | [
"Returns",
"a",
"multi",
"-",
"index",
"suitable",
"for",
"a",
"panel",
"-",
"like",
"DataFrame",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L60-L101 | [
"def",
"panel_index",
"(",
"time",
",",
"panels",
",",
"names",
"=",
"None",
")",
":",
"if",
"names",
"is",
"None",
":",
"names",
"=",
"[",
"'time'",
",",
"'panel'",
"]",
"time",
",",
"panels",
"=",
"_ensure_like_indices",
"(",
"time",
",",
"panels",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel._init_data | Generate ND initialization; axes are passed
as required objects to __init__. | pandas/core/panel.py | def _init_data(self, data, copy, dtype, **kwargs):
"""
Generate ND initialization; axes are passed
as required objects to __init__.
"""
if data is None:
data = {}
if dtype is not None:
dtype = self._validate_dtype(dtype)
passed_axes = [kwa... | def _init_data(self, data, copy, dtype, **kwargs):
"""
Generate ND initialization; axes are passed
as required objects to __init__.
"""
if data is None:
data = {}
if dtype is not None:
dtype = self._validate_dtype(dtype)
passed_axes = [kwa... | [
"Generate",
"ND",
"initialization",
";",
"axes",
"are",
"passed",
"as",
"required",
"objects",
"to",
"__init__",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L153-L192 | [
"def",
"_init_data",
"(",
"self",
",",
"data",
",",
"copy",
",",
"dtype",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"data",
"is",
"None",
":",
"data",
"=",
"{",
"}",
"if",
"dtype",
"is",
"not",
"None",
":",
"dtype",
"=",
"self",
".",
"_validate_dt... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel.from_dict | Construct Panel from dict of DataFrame objects.
Parameters
----------
data : dict
{field : DataFrame}
intersect : boolean
Intersect indexes of input DataFrames
orient : {'items', 'minor'}, default 'items'
The "orientation" of the data. If the ... | pandas/core/panel.py | def from_dict(cls, data, intersect=False, orient='items', dtype=None):
"""
Construct Panel from dict of DataFrame objects.
Parameters
----------
data : dict
{field : DataFrame}
intersect : boolean
Intersect indexes of input DataFrames
orie... | def from_dict(cls, data, intersect=False, orient='items', dtype=None):
"""
Construct Panel from dict of DataFrame objects.
Parameters
----------
data : dict
{field : DataFrame}
intersect : boolean
Intersect indexes of input DataFrames
orie... | [
"Construct",
"Panel",
"from",
"dict",
"of",
"DataFrame",
"objects",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L239-L279 | [
"def",
"from_dict",
"(",
"cls",
",",
"data",
",",
"intersect",
"=",
"False",
",",
"orient",
"=",
"'items'",
",",
"dtype",
"=",
"None",
")",
":",
"from",
"collections",
"import",
"defaultdict",
"orient",
"=",
"orient",
".",
"lower",
"(",
")",
"if",
"ori... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel._get_plane_axes_index | Get my plane axes indexes: these are already
(as compared with higher level planes),
as we are returning a DataFrame axes indexes. | pandas/core/panel.py | def _get_plane_axes_index(self, axis):
"""
Get my plane axes indexes: these are already
(as compared with higher level planes),
as we are returning a DataFrame axes indexes.
"""
axis_name = self._get_axis_name(axis)
if axis_name == 'major_axis':
index... | def _get_plane_axes_index(self, axis):
"""
Get my plane axes indexes: these are already
(as compared with higher level planes),
as we are returning a DataFrame axes indexes.
"""
axis_name = self._get_axis_name(axis)
if axis_name == 'major_axis':
index... | [
"Get",
"my",
"plane",
"axes",
"indexes",
":",
"these",
"are",
"already",
"(",
"as",
"compared",
"with",
"higher",
"level",
"planes",
")",
"as",
"we",
"are",
"returning",
"a",
"DataFrame",
"axes",
"indexes",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L368-L386 | [
"def",
"_get_plane_axes_index",
"(",
"self",
",",
"axis",
")",
":",
"axis_name",
"=",
"self",
".",
"_get_axis_name",
"(",
"axis",
")",
"if",
"axis_name",
"==",
"'major_axis'",
":",
"index",
"=",
"'minor_axis'",
"columns",
"=",
"'items'",
"if",
"axis_name",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel._get_plane_axes | Get my plane axes indexes: these are already
(as compared with higher level planes),
as we are returning a DataFrame axes. | pandas/core/panel.py | def _get_plane_axes(self, axis):
"""
Get my plane axes indexes: these are already
(as compared with higher level planes),
as we are returning a DataFrame axes.
"""
return [self._get_axis(axi)
for axi in self._get_plane_axes_index(axis)] | def _get_plane_axes(self, axis):
"""
Get my plane axes indexes: these are already
(as compared with higher level planes),
as we are returning a DataFrame axes.
"""
return [self._get_axis(axi)
for axi in self._get_plane_axes_index(axis)] | [
"Get",
"my",
"plane",
"axes",
"indexes",
":",
"these",
"are",
"already",
"(",
"as",
"compared",
"with",
"higher",
"level",
"planes",
")",
"as",
"we",
"are",
"returning",
"a",
"DataFrame",
"axes",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L388-L395 | [
"def",
"_get_plane_axes",
"(",
"self",
",",
"axis",
")",
":",
"return",
"[",
"self",
".",
"_get_axis",
"(",
"axi",
")",
"for",
"axi",
"in",
"self",
".",
"_get_plane_axes_index",
"(",
"axis",
")",
"]"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel.to_excel | Write each DataFrame in Panel to a separate excel sheet.
Parameters
----------
path : string or ExcelWriter object
File path or existing ExcelWriter
na_rep : string, default ''
Missing data representation
engine : string, default None
write en... | pandas/core/panel.py | def to_excel(self, path, na_rep='', engine=None, **kwargs):
"""
Write each DataFrame in Panel to a separate excel sheet.
Parameters
----------
path : string or ExcelWriter object
File path or existing ExcelWriter
na_rep : string, default ''
Missin... | def to_excel(self, path, na_rep='', engine=None, **kwargs):
"""
Write each DataFrame in Panel to a separate excel sheet.
Parameters
----------
path : string or ExcelWriter object
File path or existing ExcelWriter
na_rep : string, default ''
Missin... | [
"Write",
"each",
"DataFrame",
"in",
"Panel",
"to",
"a",
"separate",
"excel",
"sheet",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L409-L458 | [
"def",
"to_excel",
"(",
"self",
",",
"path",
",",
"na_rep",
"=",
"''",
",",
"engine",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"pandas",
".",
"io",
".",
"excel",
"import",
"ExcelWriter",
"if",
"isinstance",
"(",
"path",
",",
"str",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel.get_value | Quickly retrieve single value at (item, major, minor) location.
.. deprecated:: 0.21.0
Please use .at[] or .iat[] accessors.
Parameters
----------
item : item label (panel item)
major : major axis label (panel item row)
minor : minor axis label (panel item colu... | pandas/core/panel.py | def get_value(self, *args, **kwargs):
"""
Quickly retrieve single value at (item, major, minor) location.
.. deprecated:: 0.21.0
Please use .at[] or .iat[] accessors.
Parameters
----------
item : item label (panel item)
major : major axis label (panel i... | def get_value(self, *args, **kwargs):
"""
Quickly retrieve single value at (item, major, minor) location.
.. deprecated:: 0.21.0
Please use .at[] or .iat[] accessors.
Parameters
----------
item : item label (panel item)
major : major axis label (panel i... | [
"Quickly",
"retrieve",
"single",
"value",
"at",
"(",
"item",
"major",
"minor",
")",
"location",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L467-L490 | [
"def",
"get_value",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"warnings",
".",
"warn",
"(",
"\"get_value is deprecated and will be removed \"",
"\"in a future release. Please use \"",
"\".at[] or .iat[] accessors instead\"",
",",
"FutureWarning",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel.set_value | Quickly set single value at (item, major, minor) location.
.. deprecated:: 0.21.0
Please use .at[] or .iat[] accessors.
Parameters
----------
item : item label (panel item)
major : major axis label (panel item row)
minor : minor axis label (panel item column)
... | pandas/core/panel.py | def set_value(self, *args, **kwargs):
"""
Quickly set single value at (item, major, minor) location.
.. deprecated:: 0.21.0
Please use .at[] or .iat[] accessors.
Parameters
----------
item : item label (panel item)
major : major axis label (panel item r... | def set_value(self, *args, **kwargs):
"""
Quickly set single value at (item, major, minor) location.
.. deprecated:: 0.21.0
Please use .at[] or .iat[] accessors.
Parameters
----------
item : item label (panel item)
major : major axis label (panel item r... | [
"Quickly",
"set",
"single",
"value",
"at",
"(",
"item",
"major",
"minor",
")",
"location",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L515-L541 | [
"def",
"set_value",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"warnings",
".",
"warn",
"(",
"\"set_value is deprecated and will be removed \"",
"\"in a future release. Please use \"",
"\".at[] or .iat[] accessors instead\"",
",",
"FutureWarning",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel._unpickle_panel_compat | Unpickle the panel. | pandas/core/panel.py | def _unpickle_panel_compat(self, state): # pragma: no cover
"""
Unpickle the panel.
"""
from pandas.io.pickle import _unpickle_array
_unpickle = _unpickle_array
vals, items, major, minor = state
items = _unpickle(items)
major = _unpickle(major)
... | def _unpickle_panel_compat(self, state): # pragma: no cover
"""
Unpickle the panel.
"""
from pandas.io.pickle import _unpickle_array
_unpickle = _unpickle_array
vals, items, major, minor = state
items = _unpickle(items)
major = _unpickle(major)
... | [
"Unpickle",
"the",
"panel",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L615-L629 | [
"def",
"_unpickle_panel_compat",
"(",
"self",
",",
"state",
")",
":",
"# pragma: no cover",
"from",
"pandas",
".",
"io",
".",
"pickle",
"import",
"_unpickle_array",
"_unpickle",
"=",
"_unpickle_array",
"vals",
",",
"items",
",",
"major",
",",
"minor",
"=",
"st... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel.conform | Conform input DataFrame to align with chosen axis pair.
Parameters
----------
frame : DataFrame
axis : {'items', 'major', 'minor'}
Axis the input corresponds to. E.g., if axis='major', then
the frame's columns would be items, and the index would be
v... | pandas/core/panel.py | def conform(self, frame, axis='items'):
"""
Conform input DataFrame to align with chosen axis pair.
Parameters
----------
frame : DataFrame
axis : {'items', 'major', 'minor'}
Axis the input corresponds to. E.g., if axis='major', then
the frame's ... | def conform(self, frame, axis='items'):
"""
Conform input DataFrame to align with chosen axis pair.
Parameters
----------
frame : DataFrame
axis : {'items', 'major', 'minor'}
Axis the input corresponds to. E.g., if axis='major', then
the frame's ... | [
"Conform",
"input",
"DataFrame",
"to",
"align",
"with",
"chosen",
"axis",
"pair",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L631-L649 | [
"def",
"conform",
"(",
"self",
",",
"frame",
",",
"axis",
"=",
"'items'",
")",
":",
"axes",
"=",
"self",
".",
"_get_plane_axes",
"(",
"axis",
")",
"return",
"frame",
".",
"reindex",
"(",
"*",
"*",
"self",
".",
"_extract_axes_for_slice",
"(",
"self",
",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel.round | Round each value in Panel to a specified number of decimal places.
.. versionadded:: 0.18.0
Parameters
----------
decimals : int
Number of decimal places to round to (default: 0).
If decimals is negative, it specifies the number of
positions to the l... | pandas/core/panel.py | def round(self, decimals=0, *args, **kwargs):
"""
Round each value in Panel to a specified number of decimal places.
.. versionadded:: 0.18.0
Parameters
----------
decimals : int
Number of decimal places to round to (default: 0).
If decimals is n... | def round(self, decimals=0, *args, **kwargs):
"""
Round each value in Panel to a specified number of decimal places.
.. versionadded:: 0.18.0
Parameters
----------
decimals : int
Number of decimal places to round to (default: 0).
If decimals is n... | [
"Round",
"each",
"value",
"in",
"Panel",
"to",
"a",
"specified",
"number",
"of",
"decimal",
"places",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L657-L683 | [
"def",
"round",
"(",
"self",
",",
"decimals",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"nv",
".",
"validate_round",
"(",
"args",
",",
"kwargs",
")",
"if",
"is_integer",
"(",
"decimals",
")",
":",
"result",
"=",
"np",
".",
"a... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel.dropna | Drop 2D from panel, holding passed axis constant.
Parameters
----------
axis : int, default 0
Axis to hold constant. E.g. axis=1 will drop major_axis entries
having a certain amount of NA data
how : {'all', 'any'}, default 'any'
'any': one or more val... | pandas/core/panel.py | def dropna(self, axis=0, how='any', inplace=False):
"""
Drop 2D from panel, holding passed axis constant.
Parameters
----------
axis : int, default 0
Axis to hold constant. E.g. axis=1 will drop major_axis entries
having a certain amount of NA data
... | def dropna(self, axis=0, how='any', inplace=False):
"""
Drop 2D from panel, holding passed axis constant.
Parameters
----------
axis : int, default 0
Axis to hold constant. E.g. axis=1 will drop major_axis entries
having a certain amount of NA data
... | [
"Drop",
"2D",
"from",
"panel",
"holding",
"passed",
"axis",
"constant",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L694-L733 | [
"def",
"dropna",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"how",
"=",
"'any'",
",",
"inplace",
"=",
"False",
")",
":",
"axis",
"=",
"self",
".",
"_get_axis_number",
"(",
"axis",
")",
"values",
"=",
"self",
".",
"values",
"mask",
"=",
"notna",
"(",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel.xs | Return slice of panel along selected axis.
Parameters
----------
key : object
Label
axis : {'items', 'major', 'minor}, default 1/'major'
Returns
-------
y : ndim(self)-1
Notes
-----
xs is only for getting, not setting values.... | pandas/core/panel.py | def xs(self, key, axis=1):
"""
Return slice of panel along selected axis.
Parameters
----------
key : object
Label
axis : {'items', 'major', 'minor}, default 1/'major'
Returns
-------
y : ndim(self)-1
Notes
-----
... | def xs(self, key, axis=1):
"""
Return slice of panel along selected axis.
Parameters
----------
key : object
Label
axis : {'items', 'major', 'minor}, default 1/'major'
Returns
-------
y : ndim(self)-1
Notes
-----
... | [
"Return",
"slice",
"of",
"panel",
"along",
"selected",
"axis",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L834-L866 | [
"def",
"xs",
"(",
"self",
",",
"key",
",",
"axis",
"=",
"1",
")",
":",
"axis",
"=",
"self",
".",
"_get_axis_number",
"(",
"axis",
")",
"if",
"axis",
"==",
"0",
":",
"return",
"self",
"[",
"key",
"]",
"self",
".",
"_consolidate_inplace",
"(",
")",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel._ixs | Parameters
----------
i : int, slice, or sequence of integers
axis : int | pandas/core/panel.py | def _ixs(self, i, axis=0):
"""
Parameters
----------
i : int, slice, or sequence of integers
axis : int
"""
ax = self._get_axis(axis)
key = ax[i]
# xs cannot handle a non-scalar key, so just reindex here
# if we have a multi-index and a s... | def _ixs(self, i, axis=0):
"""
Parameters
----------
i : int, slice, or sequence of integers
axis : int
"""
ax = self._get_axis(axis)
key = ax[i]
# xs cannot handle a non-scalar key, so just reindex here
# if we have a multi-index and a s... | [
"Parameters",
"----------",
"i",
":",
"int",
"slice",
"or",
"sequence",
"of",
"integers",
"axis",
":",
"int"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L870-L897 | [
"def",
"_ixs",
"(",
"self",
",",
"i",
",",
"axis",
"=",
"0",
")",
":",
"ax",
"=",
"self",
".",
"_get_axis",
"(",
"axis",
")",
"key",
"=",
"ax",
"[",
"i",
"]",
"# xs cannot handle a non-scalar key, so just reindex here",
"# if we have a multi-index and a single t... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel.to_frame | Transform wide format into long (stacked) format as DataFrame whose
columns are the Panel's items and whose index is a MultiIndex formed
of the Panel's major and minor axes.
Parameters
----------
filter_observations : boolean, default True
Drop (major, minor) pairs w... | pandas/core/panel.py | def to_frame(self, filter_observations=True):
"""
Transform wide format into long (stacked) format as DataFrame whose
columns are the Panel's items and whose index is a MultiIndex formed
of the Panel's major and minor axes.
Parameters
----------
filter_observatio... | def to_frame(self, filter_observations=True):
"""
Transform wide format into long (stacked) format as DataFrame whose
columns are the Panel's items and whose index is a MultiIndex formed
of the Panel's major and minor axes.
Parameters
----------
filter_observatio... | [
"Transform",
"wide",
"format",
"into",
"long",
"(",
"stacked",
")",
"format",
"as",
"DataFrame",
"whose",
"columns",
"are",
"the",
"Panel",
"s",
"items",
"and",
"whose",
"index",
"is",
"a",
"MultiIndex",
"formed",
"of",
"the",
"Panel",
"s",
"major",
"and",... | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L915-L989 | [
"def",
"to_frame",
"(",
"self",
",",
"filter_observations",
"=",
"True",
")",
":",
"_",
",",
"N",
",",
"K",
"=",
"self",
".",
"shape",
"if",
"filter_observations",
":",
"# shaped like the return DataFrame",
"mask",
"=",
"notna",
"(",
"self",
".",
"values",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel.apply | Apply function along axis (or axes) of the Panel.
Parameters
----------
func : function
Function to apply to each combination of 'other' axes
e.g. if axis = 'items', the combination of major_axis/minor_axis
will each be passed as a Series; if axis = ('items',... | pandas/core/panel.py | def apply(self, func, axis='major', **kwargs):
"""
Apply function along axis (or axes) of the Panel.
Parameters
----------
func : function
Function to apply to each combination of 'other' axes
e.g. if axis = 'items', the combination of major_axis/minor_ax... | def apply(self, func, axis='major', **kwargs):
"""
Apply function along axis (or axes) of the Panel.
Parameters
----------
func : function
Function to apply to each combination of 'other' axes
e.g. if axis = 'items', the combination of major_axis/minor_ax... | [
"Apply",
"function",
"along",
"axis",
"(",
"or",
"axes",
")",
"of",
"the",
"Panel",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L991-L1054 | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"axis",
"=",
"'major'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
"and",
"not",
"isinstance",
"(",
"func",
",",
"np",
".",
"ufunc",
")",
":",
"f",
"=",
"lambda",
"x",
":",
"func",
"(",
"x"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel._apply_2d | Handle 2-d slices, equiv to iterating over the other axis. | pandas/core/panel.py | def _apply_2d(self, func, axis):
"""
Handle 2-d slices, equiv to iterating over the other axis.
"""
ndim = self.ndim
axis = [self._get_axis_number(a) for a in axis]
# construct slabs, in 2-d this is a DataFrame result
indexer_axis = list(range(ndim))
for ... | def _apply_2d(self, func, axis):
"""
Handle 2-d slices, equiv to iterating over the other axis.
"""
ndim = self.ndim
axis = [self._get_axis_number(a) for a in axis]
# construct slabs, in 2-d this is a DataFrame result
indexer_axis = list(range(ndim))
for ... | [
"Handle",
"2",
"-",
"d",
"slices",
"equiv",
"to",
"iterating",
"over",
"the",
"other",
"axis",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1115-L1139 | [
"def",
"_apply_2d",
"(",
"self",
",",
"func",
",",
"axis",
")",
":",
"ndim",
"=",
"self",
".",
"ndim",
"axis",
"=",
"[",
"self",
".",
"_get_axis_number",
"(",
"a",
")",
"for",
"a",
"in",
"axis",
"]",
"# construct slabs, in 2-d this is a DataFrame result",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel._construct_return_type | Return the type for the ndim of the result. | pandas/core/panel.py | def _construct_return_type(self, result, axes=None):
"""
Return the type for the ndim of the result.
"""
ndim = getattr(result, 'ndim', None)
# need to assume they are the same
if ndim is None:
if isinstance(result, dict):
ndim = getattr(list(... | def _construct_return_type(self, result, axes=None):
"""
Return the type for the ndim of the result.
"""
ndim = getattr(result, 'ndim', None)
# need to assume they are the same
if ndim is None:
if isinstance(result, dict):
ndim = getattr(list(... | [
"Return",
"the",
"type",
"for",
"the",
"ndim",
"of",
"the",
"result",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1173-L1207 | [
"def",
"_construct_return_type",
"(",
"self",
",",
"result",
",",
"axes",
"=",
"None",
")",
":",
"ndim",
"=",
"getattr",
"(",
"result",
",",
"'ndim'",
",",
"None",
")",
"# need to assume they are the same",
"if",
"ndim",
"is",
"None",
":",
"if",
"isinstance"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel.count | Return number of observations over requested axis.
Parameters
----------
axis : {'items', 'major', 'minor'} or {0, 1, 2}
Returns
-------
count : DataFrame | pandas/core/panel.py | def count(self, axis='major'):
"""
Return number of observations over requested axis.
Parameters
----------
axis : {'items', 'major', 'minor'} or {0, 1, 2}
Returns
-------
count : DataFrame
"""
i = self._get_axis_number(axis)
val... | def count(self, axis='major'):
"""
Return number of observations over requested axis.
Parameters
----------
axis : {'items', 'major', 'minor'} or {0, 1, 2}
Returns
-------
count : DataFrame
"""
i = self._get_axis_number(axis)
val... | [
"Return",
"number",
"of",
"observations",
"over",
"requested",
"axis",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1288-L1306 | [
"def",
"count",
"(",
"self",
",",
"axis",
"=",
"'major'",
")",
":",
"i",
"=",
"self",
".",
"_get_axis_number",
"(",
"axis",
")",
"values",
"=",
"self",
".",
"values",
"mask",
"=",
"np",
".",
"isfinite",
"(",
"values",
")",
"result",
"=",
"mask",
".... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel.shift | Shift index by desired number of periods with an optional time freq.
The shifted data will not include the dropped periods and the
shifted axis will be smaller than the original. This is different
from the behavior of DataFrame.shift()
Parameters
----------
periods : in... | pandas/core/panel.py | def shift(self, periods=1, freq=None, axis='major'):
"""
Shift index by desired number of periods with an optional time freq.
The shifted data will not include the dropped periods and the
shifted axis will be smaller than the original. This is different
from the behavior of Data... | def shift(self, periods=1, freq=None, axis='major'):
"""
Shift index by desired number of periods with an optional time freq.
The shifted data will not include the dropped periods and the
shifted axis will be smaller than the original. This is different
from the behavior of Data... | [
"Shift",
"index",
"by",
"desired",
"number",
"of",
"periods",
"with",
"an",
"optional",
"time",
"freq",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1308-L1330 | [
"def",
"shift",
"(",
"self",
",",
"periods",
"=",
"1",
",",
"freq",
"=",
"None",
",",
"axis",
"=",
"'major'",
")",
":",
"if",
"freq",
":",
"return",
"self",
".",
"tshift",
"(",
"periods",
",",
"freq",
",",
"axis",
"=",
"axis",
")",
"return",
"sup... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel.join | Join items with other Panel either on major and minor axes column.
Parameters
----------
other : Panel or list of Panels
Index should be similar to one of the columns in this one
how : {'left', 'right', 'outer', 'inner'}
How to handle indexes of the two objects. ... | pandas/core/panel.py | def join(self, other, how='left', lsuffix='', rsuffix=''):
"""
Join items with other Panel either on major and minor axes column.
Parameters
----------
other : Panel or list of Panels
Index should be similar to one of the columns in this one
how : {'left', 'r... | def join(self, other, how='left', lsuffix='', rsuffix=''):
"""
Join items with other Panel either on major and minor axes column.
Parameters
----------
other : Panel or list of Panels
Index should be similar to one of the columns in this one
how : {'left', 'r... | [
"Join",
"items",
"with",
"other",
"Panel",
"either",
"on",
"major",
"and",
"minor",
"axes",
"column",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1335-L1382 | [
"def",
"join",
"(",
"self",
",",
"other",
",",
"how",
"=",
"'left'",
",",
"lsuffix",
"=",
"''",
",",
"rsuffix",
"=",
"''",
")",
":",
"from",
"pandas",
".",
"core",
".",
"reshape",
".",
"concat",
"import",
"concat",
"if",
"isinstance",
"(",
"other",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel.update | Modify Panel in place using non-NA values from other Panel.
May also use object coercible to Panel. Will align on items.
Parameters
----------
other : Panel, or object coercible to Panel
The object from which the caller will be udpated.
join : {'left', 'right', 'out... | pandas/core/panel.py | def update(self, other, join='left', overwrite=True, filter_func=None,
errors='ignore'):
"""
Modify Panel in place using non-NA values from other Panel.
May also use object coercible to Panel. Will align on items.
Parameters
----------
other : Panel, or o... | def update(self, other, join='left', overwrite=True, filter_func=None,
errors='ignore'):
"""
Modify Panel in place using non-NA values from other Panel.
May also use object coercible to Panel. Will align on items.
Parameters
----------
other : Panel, or o... | [
"Modify",
"Panel",
"in",
"place",
"using",
"non",
"-",
"NA",
"values",
"from",
"other",
"Panel",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1386-L1426 | [
"def",
"update",
"(",
"self",
",",
"other",
",",
"join",
"=",
"'left'",
",",
"overwrite",
"=",
"True",
",",
"filter_func",
"=",
"None",
",",
"errors",
"=",
"'ignore'",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"self",
".",
"_constructor",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel._extract_axes | Return a list of the axis indices. | pandas/core/panel.py | def _extract_axes(self, data, axes, **kwargs):
"""
Return a list of the axis indices.
"""
return [self._extract_axis(self, data, axis=i, **kwargs)
for i, a in enumerate(axes)] | def _extract_axes(self, data, axes, **kwargs):
"""
Return a list of the axis indices.
"""
return [self._extract_axis(self, data, axis=i, **kwargs)
for i, a in enumerate(axes)] | [
"Return",
"a",
"list",
"of",
"the",
"axis",
"indices",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1443-L1448 | [
"def",
"_extract_axes",
"(",
"self",
",",
"data",
",",
"axes",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"[",
"self",
".",
"_extract_axis",
"(",
"self",
",",
"data",
",",
"axis",
"=",
"i",
",",
"*",
"*",
"kwargs",
")",
"for",
"i",
",",
"a",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel._extract_axes_for_slice | Return the slice dictionary for these axes. | pandas/core/panel.py | def _extract_axes_for_slice(self, axes):
"""
Return the slice dictionary for these axes.
"""
return {self._AXIS_SLICEMAP[i]: a for i, a in
zip(self._AXIS_ORDERS[self._AXIS_LEN - len(axes):], axes)} | def _extract_axes_for_slice(self, axes):
"""
Return the slice dictionary for these axes.
"""
return {self._AXIS_SLICEMAP[i]: a for i, a in
zip(self._AXIS_ORDERS[self._AXIS_LEN - len(axes):], axes)} | [
"Return",
"the",
"slice",
"dictionary",
"for",
"these",
"axes",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1451-L1456 | [
"def",
"_extract_axes_for_slice",
"(",
"self",
",",
"axes",
")",
":",
"return",
"{",
"self",
".",
"_AXIS_SLICEMAP",
"[",
"i",
"]",
":",
"a",
"for",
"i",
",",
"a",
"in",
"zip",
"(",
"self",
".",
"_AXIS_ORDERS",
"[",
"self",
".",
"_AXIS_LEN",
"-",
"len... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Panel._homogenize_dict | Conform set of _constructor_sliced-like objects to either
an intersection of indices / columns or a union.
Parameters
----------
frames : dict
intersect : boolean, default True
Returns
-------
dict of aligned results & indices | pandas/core/panel.py | def _homogenize_dict(self, frames, intersect=True, dtype=None):
"""
Conform set of _constructor_sliced-like objects to either
an intersection of indices / columns or a union.
Parameters
----------
frames : dict
intersect : boolean, default True
Returns
... | def _homogenize_dict(self, frames, intersect=True, dtype=None):
"""
Conform set of _constructor_sliced-like objects to either
an intersection of indices / columns or a union.
Parameters
----------
frames : dict
intersect : boolean, default True
Returns
... | [
"Conform",
"set",
"of",
"_constructor_sliced",
"-",
"like",
"objects",
"to",
"either",
"an",
"intersection",
"of",
"indices",
"/",
"columns",
"or",
"a",
"union",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1476-L1517 | [
"def",
"_homogenize_dict",
"(",
"self",
",",
"frames",
",",
"intersect",
"=",
"True",
",",
"dtype",
"=",
"None",
")",
":",
"result",
"=",
"dict",
"(",
")",
"# caller differs dict/ODict, preserved type",
"if",
"isinstance",
"(",
"frames",
",",
"OrderedDict",
")... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | get_group_index | For the particular label_list, gets the offsets into the hypothetical list
representing the totally ordered cartesian product of all possible label
combinations, *as long as* this space fits within int64 bounds;
otherwise, though group indices identify unique combinations of
labels, they cannot be decon... | pandas/core/sorting.py | def get_group_index(labels, shape, sort, xnull):
"""
For the particular label_list, gets the offsets into the hypothetical list
representing the totally ordered cartesian product of all possible label
combinations, *as long as* this space fits within int64 bounds;
otherwise, though group indices ide... | def get_group_index(labels, shape, sort, xnull):
"""
For the particular label_list, gets the offsets into the hypothetical list
representing the totally ordered cartesian product of all possible label
combinations, *as long as* this space fits within int64 bounds;
otherwise, though group indices ide... | [
"For",
"the",
"particular",
"label_list",
"gets",
"the",
"offsets",
"into",
"the",
"hypothetical",
"list",
"representing",
"the",
"totally",
"ordered",
"cartesian",
"product",
"of",
"all",
"possible",
"label",
"combinations",
"*",
"as",
"long",
"as",
"*",
"this"... | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sorting.py#L19-L99 | [
"def",
"get_group_index",
"(",
"labels",
",",
"shape",
",",
"sort",
",",
"xnull",
")",
":",
"def",
"_int64_cut_off",
"(",
"shape",
")",
":",
"acc",
"=",
"1",
"for",
"i",
",",
"mul",
"in",
"enumerate",
"(",
"shape",
")",
":",
"acc",
"*=",
"int",
"("... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | decons_obs_group_ids | reconstruct labels from observed group ids
Parameters
----------
xnull: boolean,
if nulls are excluded; i.e. -1 labels are passed through | pandas/core/sorting.py | def decons_obs_group_ids(comp_ids, obs_ids, shape, labels, xnull):
"""
reconstruct labels from observed group ids
Parameters
----------
xnull: boolean,
if nulls are excluded; i.e. -1 labels are passed through
"""
if not xnull:
lift = np.fromiter(((a == -1).any() for a in la... | def decons_obs_group_ids(comp_ids, obs_ids, shape, labels, xnull):
"""
reconstruct labels from observed group ids
Parameters
----------
xnull: boolean,
if nulls are excluded; i.e. -1 labels are passed through
"""
if not xnull:
lift = np.fromiter(((a == -1).any() for a in la... | [
"reconstruct",
"labels",
"from",
"observed",
"group",
"ids"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sorting.py#L151-L173 | [
"def",
"decons_obs_group_ids",
"(",
"comp_ids",
",",
"obs_ids",
",",
"shape",
",",
"labels",
",",
"xnull",
")",
":",
"if",
"not",
"xnull",
":",
"lift",
"=",
"np",
".",
"fromiter",
"(",
"(",
"(",
"a",
"==",
"-",
"1",
")",
".",
"any",
"(",
")",
"fo... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | nargsort | This is intended to be a drop-in replacement for np.argsort which
handles NaNs. It adds ascending and na_position parameters.
GH #6399, #5231 | pandas/core/sorting.py | def nargsort(items, kind='quicksort', ascending=True, na_position='last'):
"""
This is intended to be a drop-in replacement for np.argsort which
handles NaNs. It adds ascending and na_position parameters.
GH #6399, #5231
"""
# specially handle Categorical
if is_categorical_dtype(items):
... | def nargsort(items, kind='quicksort', ascending=True, na_position='last'):
"""
This is intended to be a drop-in replacement for np.argsort which
handles NaNs. It adds ascending and na_position parameters.
GH #6399, #5231
"""
# specially handle Categorical
if is_categorical_dtype(items):
... | [
"This",
"is",
"intended",
"to",
"be",
"a",
"drop",
"-",
"in",
"replacement",
"for",
"np",
".",
"argsort",
"which",
"handles",
"NaNs",
".",
"It",
"adds",
"ascending",
"and",
"na_position",
"parameters",
".",
"GH",
"#6399",
"#5231"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sorting.py#L234-L283 | [
"def",
"nargsort",
"(",
"items",
",",
"kind",
"=",
"'quicksort'",
",",
"ascending",
"=",
"True",
",",
"na_position",
"=",
"'last'",
")",
":",
"# specially handle Categorical",
"if",
"is_categorical_dtype",
"(",
"items",
")",
":",
"if",
"na_position",
"not",
"i... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | get_indexer_dict | return a diction of {labels} -> {indexers} | pandas/core/sorting.py | def get_indexer_dict(label_list, keys):
""" return a diction of {labels} -> {indexers} """
shape = list(map(len, keys))
group_index = get_group_index(label_list, shape, sort=True, xnull=True)
ngroups = ((group_index.size and group_index.max()) + 1) \
if is_int64_overflow_possible(shape) \
... | def get_indexer_dict(label_list, keys):
""" return a diction of {labels} -> {indexers} """
shape = list(map(len, keys))
group_index = get_group_index(label_list, shape, sort=True, xnull=True)
ngroups = ((group_index.size and group_index.max()) + 1) \
if is_int64_overflow_possible(shape) \
... | [
"return",
"a",
"diction",
"of",
"{",
"labels",
"}",
"-",
">",
"{",
"indexers",
"}"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sorting.py#L318-L332 | [
"def",
"get_indexer_dict",
"(",
"label_list",
",",
"keys",
")",
":",
"shape",
"=",
"list",
"(",
"map",
"(",
"len",
",",
"keys",
")",
")",
"group_index",
"=",
"get_group_index",
"(",
"label_list",
",",
"shape",
",",
"sort",
"=",
"True",
",",
"xnull",
"=... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | get_group_index_sorter | algos.groupsort_indexer implements `counting sort` and it is at least
O(ngroups), where
ngroups = prod(shape)
shape = map(len, keys)
that is, linear in the number of combinations (cartesian product) of unique
values of groupby keys. This can be huge when doing multi-key groupby.
np.argso... | pandas/core/sorting.py | def get_group_index_sorter(group_index, ngroups):
"""
algos.groupsort_indexer implements `counting sort` and it is at least
O(ngroups), where
ngroups = prod(shape)
shape = map(len, keys)
that is, linear in the number of combinations (cartesian product) of unique
values of groupby key... | def get_group_index_sorter(group_index, ngroups):
"""
algos.groupsort_indexer implements `counting sort` and it is at least
O(ngroups), where
ngroups = prod(shape)
shape = map(len, keys)
that is, linear in the number of combinations (cartesian product) of unique
values of groupby key... | [
"algos",
".",
"groupsort_indexer",
"implements",
"counting",
"sort",
"and",
"it",
"is",
"at",
"least",
"O",
"(",
"ngroups",
")",
"where",
"ngroups",
"=",
"prod",
"(",
"shape",
")",
"shape",
"=",
"map",
"(",
"len",
"keys",
")",
"that",
"is",
"linear",
"... | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sorting.py#L338-L362 | [
"def",
"get_group_index_sorter",
"(",
"group_index",
",",
"ngroups",
")",
":",
"count",
"=",
"len",
"(",
"group_index",
")",
"alpha",
"=",
"0.0",
"# taking complexities literally; there may be",
"beta",
"=",
"1.0",
"# some room for fine-tuning these parameters",
"do_group... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | compress_group_index | Group_index is offsets into cartesian product of all possible labels. This
space can be huge, so this function compresses it, by computing offsets
(comp_ids) into the list of unique labels (obs_group_ids). | pandas/core/sorting.py | def compress_group_index(group_index, sort=True):
"""
Group_index is offsets into cartesian product of all possible labels. This
space can be huge, so this function compresses it, by computing offsets
(comp_ids) into the list of unique labels (obs_group_ids).
"""
size_hint = min(len(group_index... | def compress_group_index(group_index, sort=True):
"""
Group_index is offsets into cartesian product of all possible labels. This
space can be huge, so this function compresses it, by computing offsets
(comp_ids) into the list of unique labels (obs_group_ids).
"""
size_hint = min(len(group_index... | [
"Group_index",
"is",
"offsets",
"into",
"cartesian",
"product",
"of",
"all",
"possible",
"labels",
".",
"This",
"space",
"can",
"be",
"huge",
"so",
"this",
"function",
"compresses",
"it",
"by",
"computing",
"offsets",
"(",
"comp_ids",
")",
"into",
"the",
"li... | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sorting.py#L365-L383 | [
"def",
"compress_group_index",
"(",
"group_index",
",",
"sort",
"=",
"True",
")",
":",
"size_hint",
"=",
"min",
"(",
"len",
"(",
"group_index",
")",
",",
"hashtable",
".",
"_SIZE_HINT_LIMIT",
")",
"table",
"=",
"hashtable",
".",
"Int64HashTable",
"(",
"size_... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | safe_sort | Sort ``values`` and reorder corresponding ``labels``.
``values`` should be unique if ``labels`` is not None.
Safe for use with mixed types (int, str), orders ints before strs.
.. versionadded:: 0.19.0
Parameters
----------
values : list-like
Sequence; must be unique if ``labels`` is no... | pandas/core/sorting.py | def safe_sort(values, labels=None, na_sentinel=-1, assume_unique=False):
"""
Sort ``values`` and reorder corresponding ``labels``.
``values`` should be unique if ``labels`` is not None.
Safe for use with mixed types (int, str), orders ints before strs.
.. versionadded:: 0.19.0
Parameters
-... | def safe_sort(values, labels=None, na_sentinel=-1, assume_unique=False):
"""
Sort ``values`` and reorder corresponding ``labels``.
``values`` should be unique if ``labels`` is not None.
Safe for use with mixed types (int, str), orders ints before strs.
.. versionadded:: 0.19.0
Parameters
-... | [
"Sort",
"values",
"and",
"reorder",
"corresponding",
"labels",
".",
"values",
"should",
"be",
"unique",
"if",
"labels",
"is",
"not",
"None",
".",
"Safe",
"for",
"use",
"with",
"mixed",
"types",
"(",
"int",
"str",
")",
"orders",
"ints",
"before",
"strs",
... | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sorting.py#L406-L507 | [
"def",
"safe_sort",
"(",
"values",
",",
"labels",
"=",
"None",
",",
"na_sentinel",
"=",
"-",
"1",
",",
"assume_unique",
"=",
"False",
")",
":",
"if",
"not",
"is_list_like",
"(",
"values",
")",
":",
"raise",
"TypeError",
"(",
"\"Only list-like objects are all... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _check_ne_builtin_clash | Attempt to prevent foot-shooting in a helpful way.
Parameters
----------
terms : Term
Terms can contain | pandas/core/computation/engines.py | def _check_ne_builtin_clash(expr):
"""Attempt to prevent foot-shooting in a helpful way.
Parameters
----------
terms : Term
Terms can contain
"""
names = expr.names
overlap = names & _ne_builtins
if overlap:
s = ', '.join(map(repr, overlap))
raise NumExprClobber... | def _check_ne_builtin_clash(expr):
"""Attempt to prevent foot-shooting in a helpful way.
Parameters
----------
terms : Term
Terms can contain
"""
names = expr.names
overlap = names & _ne_builtins
if overlap:
s = ', '.join(map(repr, overlap))
raise NumExprClobber... | [
"Attempt",
"to",
"prevent",
"foot",
"-",
"shooting",
"in",
"a",
"helpful",
"way",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/engines.py#L20-L35 | [
"def",
"_check_ne_builtin_clash",
"(",
"expr",
")",
":",
"names",
"=",
"expr",
".",
"names",
"overlap",
"=",
"names",
"&",
"_ne_builtins",
"if",
"overlap",
":",
"s",
"=",
"', '",
".",
"join",
"(",
"map",
"(",
"repr",
",",
"overlap",
")",
")",
"raise",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | AbstractEngine.evaluate | Run the engine on the expression
This method performs alignment which is necessary no matter what engine
is being used, thus its implementation is in the base class.
Returns
-------
obj : object
The result of the passed expression. | pandas/core/computation/engines.py | def evaluate(self):
"""Run the engine on the expression
This method performs alignment which is necessary no matter what engine
is being used, thus its implementation is in the base class.
Returns
-------
obj : object
The result of the passed expression.
... | def evaluate(self):
"""Run the engine on the expression
This method performs alignment which is necessary no matter what engine
is being used, thus its implementation is in the base class.
Returns
-------
obj : object
The result of the passed expression.
... | [
"Run",
"the",
"engine",
"on",
"the",
"expression"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/engines.py#L55-L72 | [
"def",
"evaluate",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_is_aligned",
":",
"self",
".",
"result_type",
",",
"self",
".",
"aligned_axes",
"=",
"_align",
"(",
"self",
".",
"expr",
".",
"terms",
")",
"# make sure no names in resolvers and locals/glob... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | get_block_type | Find the appropriate Block subclass to use for the given values and dtype.
Parameters
----------
values : ndarray-like
dtype : numpy or pandas dtype
Returns
-------
cls : class, subclass of Block | pandas/core/internals/blocks.py | def get_block_type(values, dtype=None):
"""
Find the appropriate Block subclass to use for the given values and dtype.
Parameters
----------
values : ndarray-like
dtype : numpy or pandas dtype
Returns
-------
cls : class, subclass of Block
"""
dtype = dtype or values.dtype
... | def get_block_type(values, dtype=None):
"""
Find the appropriate Block subclass to use for the given values and dtype.
Parameters
----------
values : ndarray-like
dtype : numpy or pandas dtype
Returns
-------
cls : class, subclass of Block
"""
dtype = dtype or values.dtype
... | [
"Find",
"the",
"appropriate",
"Block",
"subclass",
"to",
"use",
"for",
"the",
"given",
"values",
"and",
"dtype",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2987-L3030 | [
"def",
"get_block_type",
"(",
"values",
",",
"dtype",
"=",
"None",
")",
":",
"dtype",
"=",
"dtype",
"or",
"values",
".",
"dtype",
"vtype",
"=",
"dtype",
".",
"type",
"if",
"is_sparse",
"(",
"dtype",
")",
":",
"# Need this first(ish) so that Sparse[datetime] is... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _extend_blocks | return a new extended blocks, givin the result | pandas/core/internals/blocks.py | def _extend_blocks(result, blocks=None):
""" return a new extended blocks, givin the result """
from pandas.core.internals import BlockManager
if blocks is None:
blocks = []
if isinstance(result, list):
for r in result:
if isinstance(r, list):
blocks.extend(r)... | def _extend_blocks(result, blocks=None):
""" return a new extended blocks, givin the result """
from pandas.core.internals import BlockManager
if blocks is None:
blocks = []
if isinstance(result, list):
for r in result:
if isinstance(r, list):
blocks.extend(r)... | [
"return",
"a",
"new",
"extended",
"blocks",
"givin",
"the",
"result"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L3060-L3075 | [
"def",
"_extend_blocks",
"(",
"result",
",",
"blocks",
"=",
"None",
")",
":",
"from",
"pandas",
".",
"core",
".",
"internals",
"import",
"BlockManager",
"if",
"blocks",
"is",
"None",
":",
"blocks",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"result",
",",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _block_shape | guarantee the shape of the values to be at least 1 d | pandas/core/internals/blocks.py | def _block_shape(values, ndim=1, shape=None):
""" guarantee the shape of the values to be at least 1 d """
if values.ndim < ndim:
if shape is None:
shape = values.shape
if not is_extension_array_dtype(values):
# TODO: https://github.com/pandas-dev/pandas/issues/23023
... | def _block_shape(values, ndim=1, shape=None):
""" guarantee the shape of the values to be at least 1 d """
if values.ndim < ndim:
if shape is None:
shape = values.shape
if not is_extension_array_dtype(values):
# TODO: https://github.com/pandas-dev/pandas/issues/23023
... | [
"guarantee",
"the",
"shape",
"of",
"the",
"values",
"to",
"be",
"at",
"least",
"1",
"d"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L3078-L3088 | [
"def",
"_block_shape",
"(",
"values",
",",
"ndim",
"=",
"1",
",",
"shape",
"=",
"None",
")",
":",
"if",
"values",
".",
"ndim",
"<",
"ndim",
":",
"if",
"shape",
"is",
"None",
":",
"shape",
"=",
"values",
".",
"shape",
"if",
"not",
"is_extension_array_... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _safe_reshape | If possible, reshape `arr` to have shape `new_shape`,
with a couple of exceptions (see gh-13012):
1) If `arr` is a ExtensionArray or Index, `arr` will be
returned as is.
2) If `arr` is a Series, the `_values` attribute will
be reshaped and returned.
Parameters
----------
arr : ar... | pandas/core/internals/blocks.py | def _safe_reshape(arr, new_shape):
"""
If possible, reshape `arr` to have shape `new_shape`,
with a couple of exceptions (see gh-13012):
1) If `arr` is a ExtensionArray or Index, `arr` will be
returned as is.
2) If `arr` is a Series, the `_values` attribute will
be reshaped and return... | def _safe_reshape(arr, new_shape):
"""
If possible, reshape `arr` to have shape `new_shape`,
with a couple of exceptions (see gh-13012):
1) If `arr` is a ExtensionArray or Index, `arr` will be
returned as is.
2) If `arr` is a Series, the `_values` attribute will
be reshaped and return... | [
"If",
"possible",
"reshape",
"arr",
"to",
"have",
"shape",
"new_shape",
"with",
"a",
"couple",
"of",
"exceptions",
"(",
"see",
"gh",
"-",
"13012",
")",
":"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L3118-L3137 | [
"def",
"_safe_reshape",
"(",
"arr",
",",
"new_shape",
")",
":",
"if",
"isinstance",
"(",
"arr",
",",
"ABCSeries",
")",
":",
"arr",
"=",
"arr",
".",
"_values",
"if",
"not",
"isinstance",
"(",
"arr",
",",
"ABCExtensionArray",
")",
":",
"arr",
"=",
"arr",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | _putmask_smart | Return a new ndarray, try to preserve dtype if possible.
Parameters
----------
v : `values`, updated in-place (array like)
m : `mask`, applies to both sides (array like)
n : `new values` either scalar or an array like aligned with `values`
Returns
-------
values : ndarray with updated ... | pandas/core/internals/blocks.py | def _putmask_smart(v, m, n):
"""
Return a new ndarray, try to preserve dtype if possible.
Parameters
----------
v : `values`, updated in-place (array like)
m : `mask`, applies to both sides (array like)
n : `new values` either scalar or an array like aligned with `values`
Returns
-... | def _putmask_smart(v, m, n):
"""
Return a new ndarray, try to preserve dtype if possible.
Parameters
----------
v : `values`, updated in-place (array like)
m : `mask`, applies to both sides (array like)
n : `new values` either scalar or an array like aligned with `values`
Returns
-... | [
"Return",
"a",
"new",
"ndarray",
"try",
"to",
"preserve",
"dtype",
"if",
"possible",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L3140-L3224 | [
"def",
"_putmask_smart",
"(",
"v",
",",
"m",
",",
"n",
")",
":",
"# we cannot use np.asarray() here as we cannot have conversions",
"# that numpy does when numeric are mixed with strings",
"# n should be the length of the mask or a scalar here",
"if",
"not",
"is_list_like",
"(",
"n... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block._check_ndim | ndim inference and validation.
Infers ndim from 'values' if not provided to __init__.
Validates that values.ndim and ndim are consistent if and only if
the class variable '_validate_ndim' is True.
Parameters
----------
values : array-like
ndim : int or None
... | pandas/core/internals/blocks.py | def _check_ndim(self, values, ndim):
"""
ndim inference and validation.
Infers ndim from 'values' if not provided to __init__.
Validates that values.ndim and ndim are consistent if and only if
the class variable '_validate_ndim' is True.
Parameters
----------
... | def _check_ndim(self, values, ndim):
"""
ndim inference and validation.
Infers ndim from 'values' if not provided to __init__.
Validates that values.ndim and ndim are consistent if and only if
the class variable '_validate_ndim' is True.
Parameters
----------
... | [
"ndim",
"inference",
"and",
"validation",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L87-L116 | [
"def",
"_check_ndim",
"(",
"self",
",",
"values",
",",
"ndim",
")",
":",
"if",
"ndim",
"is",
"None",
":",
"ndim",
"=",
"values",
".",
"ndim",
"if",
"self",
".",
"_validate_ndim",
"and",
"values",
".",
"ndim",
"!=",
"ndim",
":",
"msg",
"=",
"(",
"\"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.is_categorical_astype | validate that we have a astypeable to categorical,
returns a boolean if we are a categorical | pandas/core/internals/blocks.py | def is_categorical_astype(self, dtype):
"""
validate that we have a astypeable to categorical,
returns a boolean if we are a categorical
"""
if dtype is Categorical or dtype is CategoricalDtype:
# this is a pd.Categorical, but is not
# a valid type for ast... | def is_categorical_astype(self, dtype):
"""
validate that we have a astypeable to categorical,
returns a boolean if we are a categorical
"""
if dtype is Categorical or dtype is CategoricalDtype:
# this is a pd.Categorical, but is not
# a valid type for ast... | [
"validate",
"that",
"we",
"have",
"a",
"astypeable",
"to",
"categorical",
"returns",
"a",
"boolean",
"if",
"we",
"are",
"a",
"categorical"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L145-L158 | [
"def",
"is_categorical_astype",
"(",
"self",
",",
"dtype",
")",
":",
"if",
"dtype",
"is",
"Categorical",
"or",
"dtype",
"is",
"CategoricalDtype",
":",
"# this is a pd.Categorical, but is not",
"# a valid type for astypeing",
"raise",
"TypeError",
"(",
"\"invalid type {0} ... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.get_values | return an internal format, currently just the ndarray
this is often overridden to handle to_dense like operations | pandas/core/internals/blocks.py | def get_values(self, dtype=None):
"""
return an internal format, currently just the ndarray
this is often overridden to handle to_dense like operations
"""
if is_object_dtype(dtype):
return self.values.astype(object)
return self.values | def get_values(self, dtype=None):
"""
return an internal format, currently just the ndarray
this is often overridden to handle to_dense like operations
"""
if is_object_dtype(dtype):
return self.values.astype(object)
return self.values | [
"return",
"an",
"internal",
"format",
"currently",
"just",
"the",
"ndarray",
"this",
"is",
"often",
"overridden",
"to",
"handle",
"to_dense",
"like",
"operations"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L174-L181 | [
"def",
"get_values",
"(",
"self",
",",
"dtype",
"=",
"None",
")",
":",
"if",
"is_object_dtype",
"(",
"dtype",
")",
":",
"return",
"self",
".",
"values",
".",
"astype",
"(",
"object",
")",
"return",
"self",
".",
"values"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.make_block | Create a new block, with type inference propagate any values that are
not specified | pandas/core/internals/blocks.py | def make_block(self, values, placement=None, ndim=None):
"""
Create a new block, with type inference propagate any values that are
not specified
"""
if placement is None:
placement = self.mgr_locs
if ndim is None:
ndim = self.ndim
return m... | def make_block(self, values, placement=None, ndim=None):
"""
Create a new block, with type inference propagate any values that are
not specified
"""
if placement is None:
placement = self.mgr_locs
if ndim is None:
ndim = self.ndim
return m... | [
"Create",
"a",
"new",
"block",
"with",
"type",
"inference",
"propagate",
"any",
"values",
"that",
"are",
"not",
"specified"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L212-L222 | [
"def",
"make_block",
"(",
"self",
",",
"values",
",",
"placement",
"=",
"None",
",",
"ndim",
"=",
"None",
")",
":",
"if",
"placement",
"is",
"None",
":",
"placement",
"=",
"self",
".",
"mgr_locs",
"if",
"ndim",
"is",
"None",
":",
"ndim",
"=",
"self",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.make_block_same_class | Wrap given values in a block of same type as self. | pandas/core/internals/blocks.py | def make_block_same_class(self, values, placement=None, ndim=None,
dtype=None):
""" Wrap given values in a block of same type as self. """
if dtype is not None:
# issue 19431 fastparquet is passing this
warnings.warn("dtype argument is deprecated, wi... | def make_block_same_class(self, values, placement=None, ndim=None,
dtype=None):
""" Wrap given values in a block of same type as self. """
if dtype is not None:
# issue 19431 fastparquet is passing this
warnings.warn("dtype argument is deprecated, wi... | [
"Wrap",
"given",
"values",
"in",
"a",
"block",
"of",
"same",
"type",
"as",
"self",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L224-L234 | [
"def",
"make_block_same_class",
"(",
"self",
",",
"values",
",",
"placement",
"=",
"None",
",",
"ndim",
"=",
"None",
",",
"dtype",
"=",
"None",
")",
":",
"if",
"dtype",
"is",
"not",
"None",
":",
"# issue 19431 fastparquet is passing this",
"warnings",
".",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.getitem_block | Perform __getitem__-like, return result as block.
As of now, only supports slices that preserve dimensionality. | pandas/core/internals/blocks.py | def getitem_block(self, slicer, new_mgr_locs=None):
"""
Perform __getitem__-like, return result as block.
As of now, only supports slices that preserve dimensionality.
"""
if new_mgr_locs is None:
if isinstance(slicer, tuple):
axis0_slicer = slicer[0]... | def getitem_block(self, slicer, new_mgr_locs=None):
"""
Perform __getitem__-like, return result as block.
As of now, only supports slices that preserve dimensionality.
"""
if new_mgr_locs is None:
if isinstance(slicer, tuple):
axis0_slicer = slicer[0]... | [
"Perform",
"__getitem__",
"-",
"like",
"return",
"result",
"as",
"block",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L269-L287 | [
"def",
"getitem_block",
"(",
"self",
",",
"slicer",
",",
"new_mgr_locs",
"=",
"None",
")",
":",
"if",
"new_mgr_locs",
"is",
"None",
":",
"if",
"isinstance",
"(",
"slicer",
",",
"tuple",
")",
":",
"axis0_slicer",
"=",
"slicer",
"[",
"0",
"]",
"else",
":... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.concat_same_type | Concatenate list of single blocks of the same type. | pandas/core/internals/blocks.py | def concat_same_type(self, to_concat, placement=None):
"""
Concatenate list of single blocks of the same type.
"""
values = self._concatenator([blk.values for blk in to_concat],
axis=self.ndim - 1)
return self.make_block_same_class(
... | def concat_same_type(self, to_concat, placement=None):
"""
Concatenate list of single blocks of the same type.
"""
values = self._concatenator([blk.values for blk in to_concat],
axis=self.ndim - 1)
return self.make_block_same_class(
... | [
"Concatenate",
"list",
"of",
"single",
"blocks",
"of",
"the",
"same",
"type",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L308-L315 | [
"def",
"concat_same_type",
"(",
"self",
",",
"to_concat",
",",
"placement",
"=",
"None",
")",
":",
"values",
"=",
"self",
".",
"_concatenator",
"(",
"[",
"blk",
".",
"values",
"for",
"blk",
"in",
"to_concat",
"]",
",",
"axis",
"=",
"self",
".",
"ndim",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.delete | Delete given loc(-s) from block in-place. | pandas/core/internals/blocks.py | def delete(self, loc):
"""
Delete given loc(-s) from block in-place.
"""
self.values = np.delete(self.values, loc, 0)
self.mgr_locs = self.mgr_locs.delete(loc) | def delete(self, loc):
"""
Delete given loc(-s) from block in-place.
"""
self.values = np.delete(self.values, loc, 0)
self.mgr_locs = self.mgr_locs.delete(loc) | [
"Delete",
"given",
"loc",
"(",
"-",
"s",
")",
"from",
"block",
"in",
"-",
"place",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L330-L335 | [
"def",
"delete",
"(",
"self",
",",
"loc",
")",
":",
"self",
".",
"values",
"=",
"np",
".",
"delete",
"(",
"self",
".",
"values",
",",
"loc",
",",
"0",
")",
"self",
".",
"mgr_locs",
"=",
"self",
".",
"mgr_locs",
".",
"delete",
"(",
"loc",
")"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.apply | apply the function to my values; return a block if we are not
one | pandas/core/internals/blocks.py | def apply(self, func, **kwargs):
""" apply the function to my values; return a block if we are not
one
"""
with np.errstate(all='ignore'):
result = func(self.values, **kwargs)
if not isinstance(result, Block):
result = self.make_block(values=_block_shape(r... | def apply(self, func, **kwargs):
""" apply the function to my values; return a block if we are not
one
"""
with np.errstate(all='ignore'):
result = func(self.values, **kwargs)
if not isinstance(result, Block):
result = self.make_block(values=_block_shape(r... | [
"apply",
"the",
"function",
"to",
"my",
"values",
";",
"return",
"a",
"block",
"if",
"we",
"are",
"not",
"one"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L337-L347 | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"np",
".",
"errstate",
"(",
"all",
"=",
"'ignore'",
")",
":",
"result",
"=",
"func",
"(",
"self",
".",
"values",
",",
"*",
"*",
"kwargs",
")",
"if",
"not",
"is... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.fillna | fillna on the block with the value. If we fail, then convert to
ObjectBlock and try again | pandas/core/internals/blocks.py | def fillna(self, value, limit=None, inplace=False, downcast=None):
""" fillna on the block with the value. If we fail, then convert to
ObjectBlock and try again
"""
inplace = validate_bool_kwarg(inplace, 'inplace')
if not self._can_hold_na:
if inplace:
... | def fillna(self, value, limit=None, inplace=False, downcast=None):
""" fillna on the block with the value. If we fail, then convert to
ObjectBlock and try again
"""
inplace = validate_bool_kwarg(inplace, 'inplace')
if not self._can_hold_na:
if inplace:
... | [
"fillna",
"on",
"the",
"block",
"with",
"the",
"value",
".",
"If",
"we",
"fail",
"then",
"convert",
"to",
"ObjectBlock",
"and",
"try",
"again"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L349-L397 | [
"def",
"fillna",
"(",
"self",
",",
"value",
",",
"limit",
"=",
"None",
",",
"inplace",
"=",
"False",
",",
"downcast",
"=",
"None",
")",
":",
"inplace",
"=",
"validate_bool_kwarg",
"(",
"inplace",
",",
"'inplace'",
")",
"if",
"not",
"self",
".",
"_can_h... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.split_and_operate | split the block per-column, and apply the callable f
per-column, return a new block for each. Handle
masking which will not change a block unless needed.
Parameters
----------
mask : 2-d boolean mask
f : callable accepting (1d-mask, 1d values, indexer)
inplace : ... | pandas/core/internals/blocks.py | def split_and_operate(self, mask, f, inplace):
"""
split the block per-column, and apply the callable f
per-column, return a new block for each. Handle
masking which will not change a block unless needed.
Parameters
----------
mask : 2-d boolean mask
f : ... | def split_and_operate(self, mask, f, inplace):
"""
split the block per-column, and apply the callable f
per-column, return a new block for each. Handle
masking which will not change a block unless needed.
Parameters
----------
mask : 2-d boolean mask
f : ... | [
"split",
"the",
"block",
"per",
"-",
"column",
"and",
"apply",
"the",
"callable",
"f",
"per",
"-",
"column",
"return",
"a",
"new",
"block",
"for",
"each",
".",
"Handle",
"masking",
"which",
"will",
"not",
"change",
"a",
"block",
"unless",
"needed",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L399-L460 | [
"def",
"split_and_operate",
"(",
"self",
",",
"mask",
",",
"f",
",",
"inplace",
")",
":",
"if",
"mask",
"is",
"None",
":",
"mask",
"=",
"np",
".",
"ones",
"(",
"self",
".",
"shape",
",",
"dtype",
"=",
"bool",
")",
"new_values",
"=",
"self",
".",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.downcast | try to downcast each item to the dict of dtypes if present | pandas/core/internals/blocks.py | def downcast(self, dtypes=None):
""" try to downcast each item to the dict of dtypes if present """
# turn it off completely
if dtypes is False:
return self
values = self.values
# single block handling
if self._is_single_block:
# try to cast al... | def downcast(self, dtypes=None):
""" try to downcast each item to the dict of dtypes if present """
# turn it off completely
if dtypes is False:
return self
values = self.values
# single block handling
if self._is_single_block:
# try to cast al... | [
"try",
"to",
"downcast",
"each",
"item",
"to",
"the",
"dict",
"of",
"dtypes",
"if",
"present"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L475-L515 | [
"def",
"downcast",
"(",
"self",
",",
"dtypes",
"=",
"None",
")",
":",
"# turn it off completely",
"if",
"dtypes",
"is",
"False",
":",
"return",
"self",
"values",
"=",
"self",
".",
"values",
"# single block handling",
"if",
"self",
".",
"_is_single_block",
":",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block._astype | Coerce to the new type
Parameters
----------
dtype : str, dtype convertible
copy : boolean, default False
copy if indicated
errors : str, {'raise', 'ignore'}, default 'ignore'
- ``raise`` : allow exceptions to be raised
- ``ignore`` : suppress... | pandas/core/internals/blocks.py | def _astype(self, dtype, copy=False, errors='raise', values=None,
**kwargs):
"""Coerce to the new type
Parameters
----------
dtype : str, dtype convertible
copy : boolean, default False
copy if indicated
errors : str, {'raise', 'ignore'}, defa... | def _astype(self, dtype, copy=False, errors='raise', values=None,
**kwargs):
"""Coerce to the new type
Parameters
----------
dtype : str, dtype convertible
copy : boolean, default False
copy if indicated
errors : str, {'raise', 'ignore'}, defa... | [
"Coerce",
"to",
"the",
"new",
"type"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L521-L633 | [
"def",
"_astype",
"(",
"self",
",",
"dtype",
",",
"copy",
"=",
"False",
",",
"errors",
"=",
"'raise'",
",",
"values",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"errors_legal_values",
"=",
"(",
"'raise'",
",",
"'ignore'",
")",
"if",
"errors",
"n... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block._can_hold_element | require the same dtype as ourselves | pandas/core/internals/blocks.py | def _can_hold_element(self, element):
""" require the same dtype as ourselves """
dtype = self.values.dtype.type
tipo = maybe_infer_dtype_type(element)
if tipo is not None:
return issubclass(tipo.type, dtype)
return isinstance(element, dtype) | def _can_hold_element(self, element):
""" require the same dtype as ourselves """
dtype = self.values.dtype.type
tipo = maybe_infer_dtype_type(element)
if tipo is not None:
return issubclass(tipo.type, dtype)
return isinstance(element, dtype) | [
"require",
"the",
"same",
"dtype",
"as",
"ourselves"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L643-L649 | [
"def",
"_can_hold_element",
"(",
"self",
",",
"element",
")",
":",
"dtype",
"=",
"self",
".",
"values",
".",
"dtype",
".",
"type",
"tipo",
"=",
"maybe_infer_dtype_type",
"(",
"element",
")",
"if",
"tipo",
"is",
"not",
"None",
":",
"return",
"issubclass",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block._try_cast_result | try to cast the result to our original type, we may have
roundtripped thru object in the mean-time | pandas/core/internals/blocks.py | def _try_cast_result(self, result, dtype=None):
""" try to cast the result to our original type, we may have
roundtripped thru object in the mean-time
"""
if dtype is None:
dtype = self.dtype
if self.is_integer or self.is_bool or self.is_datetime:
pass
... | def _try_cast_result(self, result, dtype=None):
""" try to cast the result to our original type, we may have
roundtripped thru object in the mean-time
"""
if dtype is None:
dtype = self.dtype
if self.is_integer or self.is_bool or self.is_datetime:
pass
... | [
"try",
"to",
"cast",
"the",
"result",
"to",
"our",
"original",
"type",
"we",
"may",
"have",
"roundtripped",
"thru",
"object",
"in",
"the",
"mean",
"-",
"time"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L651-L682 | [
"def",
"_try_cast_result",
"(",
"self",
",",
"result",
",",
"dtype",
"=",
"None",
")",
":",
"if",
"dtype",
"is",
"None",
":",
"dtype",
"=",
"self",
".",
"dtype",
"if",
"self",
".",
"is_integer",
"or",
"self",
".",
"is_bool",
"or",
"self",
".",
"is_da... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block._try_coerce_args | provide coercion to our input arguments | pandas/core/internals/blocks.py | def _try_coerce_args(self, values, other):
""" provide coercion to our input arguments """
if np.any(notna(other)) and not self._can_hold_element(other):
# coercion issues
# let higher levels handle
raise TypeError("cannot convert {} to an {}".format(
... | def _try_coerce_args(self, values, other):
""" provide coercion to our input arguments """
if np.any(notna(other)) and not self._can_hold_element(other):
# coercion issues
# let higher levels handle
raise TypeError("cannot convert {} to an {}".format(
... | [
"provide",
"coercion",
"to",
"our",
"input",
"arguments"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L684-L694 | [
"def",
"_try_coerce_args",
"(",
"self",
",",
"values",
",",
"other",
")",
":",
"if",
"np",
".",
"any",
"(",
"notna",
"(",
"other",
")",
")",
"and",
"not",
"self",
".",
"_can_hold_element",
"(",
"other",
")",
":",
"# coercion issues",
"# let higher levels h... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.to_native_types | convert to our native types format, slicing if desired | pandas/core/internals/blocks.py | def to_native_types(self, slicer=None, na_rep='nan', quoting=None,
**kwargs):
""" convert to our native types format, slicing if desired """
values = self.get_values()
if slicer is not None:
values = values[:, slicer]
mask = isna(values)
if ... | def to_native_types(self, slicer=None, na_rep='nan', quoting=None,
**kwargs):
""" convert to our native types format, slicing if desired """
values = self.get_values()
if slicer is not None:
values = values[:, slicer]
mask = isna(values)
if ... | [
"convert",
"to",
"our",
"native",
"types",
"format",
"slicing",
"if",
"desired"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L705-L721 | [
"def",
"to_native_types",
"(",
"self",
",",
"slicer",
"=",
"None",
",",
"na_rep",
"=",
"'nan'",
",",
"quoting",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"values",
"=",
"self",
".",
"get_values",
"(",
")",
"if",
"slicer",
"is",
"not",
"None",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.copy | copy constructor | pandas/core/internals/blocks.py | def copy(self, deep=True):
""" copy constructor """
values = self.values
if deep:
values = values.copy()
return self.make_block_same_class(values, ndim=self.ndim) | def copy(self, deep=True):
""" copy constructor """
values = self.values
if deep:
values = values.copy()
return self.make_block_same_class(values, ndim=self.ndim) | [
"copy",
"constructor"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L724-L729 | [
"def",
"copy",
"(",
"self",
",",
"deep",
"=",
"True",
")",
":",
"values",
"=",
"self",
".",
"values",
"if",
"deep",
":",
"values",
"=",
"values",
".",
"copy",
"(",
")",
"return",
"self",
".",
"make_block_same_class",
"(",
"values",
",",
"ndim",
"=",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.replace | replace the to_replace value with value, possible to create new
blocks here this is just a call to putmask. regex is not used here.
It is used in ObjectBlocks. It is here for API compatibility. | pandas/core/internals/blocks.py | def replace(self, to_replace, value, inplace=False, filter=None,
regex=False, convert=True):
"""replace the to_replace value with value, possible to create new
blocks here this is just a call to putmask. regex is not used here.
It is used in ObjectBlocks. It is here for API comp... | def replace(self, to_replace, value, inplace=False, filter=None,
regex=False, convert=True):
"""replace the to_replace value with value, possible to create new
blocks here this is just a call to putmask. regex is not used here.
It is used in ObjectBlocks. It is here for API comp... | [
"replace",
"the",
"to_replace",
"value",
"with",
"value",
"possible",
"to",
"create",
"new",
"blocks",
"here",
"this",
"is",
"just",
"a",
"call",
"to",
"putmask",
".",
"regex",
"is",
"not",
"used",
"here",
".",
"It",
"is",
"used",
"in",
"ObjectBlocks",
"... | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L731-L769 | [
"def",
"replace",
"(",
"self",
",",
"to_replace",
",",
"value",
",",
"inplace",
"=",
"False",
",",
"filter",
"=",
"None",
",",
"regex",
"=",
"False",
",",
"convert",
"=",
"True",
")",
":",
"inplace",
"=",
"validate_bool_kwarg",
"(",
"inplace",
",",
"'i... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.setitem | Set the value inplace, returning a a maybe different typed block.
Parameters
----------
indexer : tuple, list-like, array-like, slice
The subset of self.values to set
value : object
The value being set
Returns
-------
Block
Notes... | pandas/core/internals/blocks.py | def setitem(self, indexer, value):
"""Set the value inplace, returning a a maybe different typed block.
Parameters
----------
indexer : tuple, list-like, array-like, slice
The subset of self.values to set
value : object
The value being set
Return... | def setitem(self, indexer, value):
"""Set the value inplace, returning a a maybe different typed block.
Parameters
----------
indexer : tuple, list-like, array-like, slice
The subset of self.values to set
value : object
The value being set
Return... | [
"Set",
"the",
"value",
"inplace",
"returning",
"a",
"a",
"maybe",
"different",
"typed",
"block",
"."
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L775-L900 | [
"def",
"setitem",
"(",
"self",
",",
"indexer",
",",
"value",
")",
":",
"# coerce None values, if appropriate",
"if",
"value",
"is",
"None",
":",
"if",
"self",
".",
"is_numeric",
":",
"value",
"=",
"np",
".",
"nan",
"# coerce if block dtype can store value",
"val... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.putmask | putmask the data to the block; it is possible that we may create a
new dtype of block
return the resulting block(s)
Parameters
----------
mask : the condition to respect
new : a ndarray/object
align : boolean, perform alignment on other/cond, default is True
... | pandas/core/internals/blocks.py | def putmask(self, mask, new, align=True, inplace=False, axis=0,
transpose=False):
""" putmask the data to the block; it is possible that we may create a
new dtype of block
return the resulting block(s)
Parameters
----------
mask : the condition to respe... | def putmask(self, mask, new, align=True, inplace=False, axis=0,
transpose=False):
""" putmask the data to the block; it is possible that we may create a
new dtype of block
return the resulting block(s)
Parameters
----------
mask : the condition to respe... | [
"putmask",
"the",
"data",
"to",
"the",
"block",
";",
"it",
"is",
"possible",
"that",
"we",
"may",
"create",
"a",
"new",
"dtype",
"of",
"block"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L902-L1012 | [
"def",
"putmask",
"(",
"self",
",",
"mask",
",",
"new",
",",
"align",
"=",
"True",
",",
"inplace",
"=",
"False",
",",
"axis",
"=",
"0",
",",
"transpose",
"=",
"False",
")",
":",
"new_values",
"=",
"self",
".",
"values",
"if",
"inplace",
"else",
"se... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.coerce_to_target_dtype | coerce the current block to a dtype compat for other
we will return a block, possibly object, and not raise
we can also safely try to coerce to the same dtype
and will receive the same block | pandas/core/internals/blocks.py | def coerce_to_target_dtype(self, other):
"""
coerce the current block to a dtype compat for other
we will return a block, possibly object, and not raise
we can also safely try to coerce to the same dtype
and will receive the same block
"""
# if we cannot then co... | def coerce_to_target_dtype(self, other):
"""
coerce the current block to a dtype compat for other
we will return a block, possibly object, and not raise
we can also safely try to coerce to the same dtype
and will receive the same block
"""
# if we cannot then co... | [
"coerce",
"the",
"current",
"block",
"to",
"a",
"dtype",
"compat",
"for",
"other",
"we",
"will",
"return",
"a",
"block",
"possibly",
"object",
"and",
"not",
"raise"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1014-L1073 | [
"def",
"coerce_to_target_dtype",
"(",
"self",
",",
"other",
")",
":",
"# if we cannot then coerce to object",
"dtype",
",",
"_",
"=",
"infer_dtype_from",
"(",
"other",
",",
"pandas_dtype",
"=",
"True",
")",
"if",
"is_dtype_equal",
"(",
"self",
".",
"dtype",
",",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block._interpolate_with_fill | fillna but using the interpolate machinery | pandas/core/internals/blocks.py | def _interpolate_with_fill(self, method='pad', axis=0, inplace=False,
limit=None, fill_value=None, coerce=False,
downcast=None):
""" fillna but using the interpolate machinery """
inplace = validate_bool_kwarg(inplace, 'inplace')
# ... | def _interpolate_with_fill(self, method='pad', axis=0, inplace=False,
limit=None, fill_value=None, coerce=False,
downcast=None):
""" fillna but using the interpolate machinery """
inplace = validate_bool_kwarg(inplace, 'inplace')
# ... | [
"fillna",
"but",
"using",
"the",
"interpolate",
"machinery"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1119-L1143 | [
"def",
"_interpolate_with_fill",
"(",
"self",
",",
"method",
"=",
"'pad'",
",",
"axis",
"=",
"0",
",",
"inplace",
"=",
"False",
",",
"limit",
"=",
"None",
",",
"fill_value",
"=",
"None",
",",
"coerce",
"=",
"False",
",",
"downcast",
"=",
"None",
")",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block._interpolate | interpolate using scipy wrappers | pandas/core/internals/blocks.py | def _interpolate(self, method=None, index=None, values=None,
fill_value=None, axis=0, limit=None,
limit_direction='forward', limit_area=None,
inplace=False, downcast=None, **kwargs):
""" interpolate using scipy wrappers """
inplace = valida... | def _interpolate(self, method=None, index=None, values=None,
fill_value=None, axis=0, limit=None,
limit_direction='forward', limit_area=None,
inplace=False, downcast=None, **kwargs):
""" interpolate using scipy wrappers """
inplace = valida... | [
"interpolate",
"using",
"scipy",
"wrappers"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1145-L1184 | [
"def",
"_interpolate",
"(",
"self",
",",
"method",
"=",
"None",
",",
"index",
"=",
"None",
",",
"values",
"=",
"None",
",",
"fill_value",
"=",
"None",
",",
"axis",
"=",
"0",
",",
"limit",
"=",
"None",
",",
"limit_direction",
"=",
"'forward'",
",",
"l... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.take_nd | Take values according to indexer and return them as a block.bb | pandas/core/internals/blocks.py | def take_nd(self, indexer, axis, new_mgr_locs=None, fill_tuple=None):
"""
Take values according to indexer and return them as a block.bb
"""
# algos.take_nd dispatches for DatetimeTZBlock, CategoricalBlock
# so need to preserve types
# sparse is treated like an ndarray,... | def take_nd(self, indexer, axis, new_mgr_locs=None, fill_tuple=None):
"""
Take values according to indexer and return them as a block.bb
"""
# algos.take_nd dispatches for DatetimeTZBlock, CategoricalBlock
# so need to preserve types
# sparse is treated like an ndarray,... | [
"Take",
"values",
"according",
"to",
"indexer",
"and",
"return",
"them",
"as",
"a",
"block",
".",
"bb"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1186-L1222 | [
"def",
"take_nd",
"(",
"self",
",",
"indexer",
",",
"axis",
",",
"new_mgr_locs",
"=",
"None",
",",
"fill_tuple",
"=",
"None",
")",
":",
"# algos.take_nd dispatches for DatetimeTZBlock, CategoricalBlock",
"# so need to preserve types",
"# sparse is treated like an ndarray, but... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.diff | return block for the diff of the values | pandas/core/internals/blocks.py | def diff(self, n, axis=1):
""" return block for the diff of the values """
new_values = algos.diff(self.values, n, axis=axis)
return [self.make_block(values=new_values)] | def diff(self, n, axis=1):
""" return block for the diff of the values """
new_values = algos.diff(self.values, n, axis=axis)
return [self.make_block(values=new_values)] | [
"return",
"block",
"for",
"the",
"diff",
"of",
"the",
"values"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1224-L1227 | [
"def",
"diff",
"(",
"self",
",",
"n",
",",
"axis",
"=",
"1",
")",
":",
"new_values",
"=",
"algos",
".",
"diff",
"(",
"self",
".",
"values",
",",
"n",
",",
"axis",
"=",
"axis",
")",
"return",
"[",
"self",
".",
"make_block",
"(",
"values",
"=",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.shift | shift the block by periods, possibly upcast | pandas/core/internals/blocks.py | def shift(self, periods, axis=0, fill_value=None):
""" shift the block by periods, possibly upcast """
# convert integer to float if necessary. need to do a lot more than
# that, handle boolean etc also
new_values, fill_value = maybe_upcast(self.values, fill_value)
# make sure ... | def shift(self, periods, axis=0, fill_value=None):
""" shift the block by periods, possibly upcast """
# convert integer to float if necessary. need to do a lot more than
# that, handle boolean etc also
new_values, fill_value = maybe_upcast(self.values, fill_value)
# make sure ... | [
"shift",
"the",
"block",
"by",
"periods",
"possibly",
"upcast"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1229-L1257 | [
"def",
"shift",
"(",
"self",
",",
"periods",
",",
"axis",
"=",
"0",
",",
"fill_value",
"=",
"None",
")",
":",
"# convert integer to float if necessary. need to do a lot more than",
"# that, handle boolean etc also",
"new_values",
",",
"fill_value",
"=",
"maybe_upcast",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.where | evaluate the block; return result block(s) from the result
Parameters
----------
other : a ndarray/object
cond : the condition to respect
align : boolean, perform alignment on other/cond
errors : str, {'raise', 'ignore'}, default 'raise'
- ``raise`` : allow ... | pandas/core/internals/blocks.py | def where(self, other, cond, align=True, errors='raise',
try_cast=False, axis=0, transpose=False):
"""
evaluate the block; return result block(s) from the result
Parameters
----------
other : a ndarray/object
cond : the condition to respect
align :... | def where(self, other, cond, align=True, errors='raise',
try_cast=False, axis=0, transpose=False):
"""
evaluate the block; return result block(s) from the result
Parameters
----------
other : a ndarray/object
cond : the condition to respect
align :... | [
"evaluate",
"the",
"block",
";",
"return",
"result",
"block",
"(",
"s",
")",
"from",
"the",
"result"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1259-L1365 | [
"def",
"where",
"(",
"self",
",",
"other",
",",
"cond",
",",
"align",
"=",
"True",
",",
"errors",
"=",
"'raise'",
",",
"try_cast",
"=",
"False",
",",
"axis",
"=",
"0",
",",
"transpose",
"=",
"False",
")",
":",
"import",
"pandas",
".",
"core",
".",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block._unstack | Return a list of unstacked blocks of self
Parameters
----------
unstacker_func : callable
Partially applied unstacker.
new_columns : Index
All columns of the unstacked BlockManager.
n_rows : int
Only used in ExtensionBlock.unstack
fill... | pandas/core/internals/blocks.py | def _unstack(self, unstacker_func, new_columns, n_rows, fill_value):
"""Return a list of unstacked blocks of self
Parameters
----------
unstacker_func : callable
Partially applied unstacker.
new_columns : Index
All columns of the unstacked BlockManager.
... | def _unstack(self, unstacker_func, new_columns, n_rows, fill_value):
"""Return a list of unstacked blocks of self
Parameters
----------
unstacker_func : callable
Partially applied unstacker.
new_columns : Index
All columns of the unstacked BlockManager.
... | [
"Return",
"a",
"list",
"of",
"unstacked",
"blocks",
"of",
"self"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1372-L1403 | [
"def",
"_unstack",
"(",
"self",
",",
"unstacker_func",
",",
"new_columns",
",",
"n_rows",
",",
"fill_value",
")",
":",
"unstacker",
"=",
"unstacker_func",
"(",
"self",
".",
"values",
".",
"T",
")",
"new_items",
"=",
"unstacker",
".",
"get_new_columns",
"(",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
train | Block.quantile | compute the quantiles of the
Parameters
----------
qs: a scalar or list of the quantiles to be computed
interpolation: type of interpolation, default 'linear'
axis: axis to compute, default 0
Returns
-------
Block | pandas/core/internals/blocks.py | def quantile(self, qs, interpolation='linear', axis=0):
"""
compute the quantiles of the
Parameters
----------
qs: a scalar or list of the quantiles to be computed
interpolation: type of interpolation, default 'linear'
axis: axis to compute, default 0
Re... | def quantile(self, qs, interpolation='linear', axis=0):
"""
compute the quantiles of the
Parameters
----------
qs: a scalar or list of the quantiles to be computed
interpolation: type of interpolation, default 'linear'
axis: axis to compute, default 0
Re... | [
"compute",
"the",
"quantiles",
"of",
"the"
] | pandas-dev/pandas | python | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1405-L1472 | [
"def",
"quantile",
"(",
"self",
",",
"qs",
",",
"interpolation",
"=",
"'linear'",
",",
"axis",
"=",
"0",
")",
":",
"if",
"self",
".",
"is_datetimetz",
":",
"# TODO: cleanup this special case.",
"# We need to operate on i8 values for datetimetz",
"# but `Block.get_values... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.