id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
19,500
pandas-dev/pandas
pandas/core/dtypes/inference.py
is_nested_list_like
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. ...
python
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", ")", ":", "return", "(", "is_list_like", "(", "obj", ")", "and", "hasattr", "(", "obj", ",", "'__len__'", ")", "and", "len", "(", "obj", ")", ">", "0", "and", "all", "(", "is_list_like", "(", "item", ")", "fo...
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_...
[ "Check", "if", "the", "object", "is", "list", "-", "like", "and", "that", "all", "of", "its", "elements", "are", "also", "list", "-", "like", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/inference.py#L329-L370
19,501
pandas-dev/pandas
pandas/core/dtypes/inference.py
is_dict_like
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, ...
python
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", ")", ":", "dict_like_attrs", "=", "(", "\"__getitem__\"", ",", "\"keys\"", ",", "\"__contains__\"", ")", "return", "(", "all", "(", "hasattr", "(", "obj", ",", "attr", ")", "for", "attr", "in", "dict_like_attrs", ")", "# ...
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(...
[ "Check", "if", "the", "object", "is", "dict", "-", "like", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/inference.py#L373-L400
19,502
pandas-dev/pandas
pandas/core/dtypes/inference.py
is_sequence
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 -------- ...
python
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", ")", ":", "try", ":", "iter", "(", "obj", ")", "# Can iterate over it.", "len", "(", "obj", ")", "# Has a length associated with it.", "return", "not", "isinstance", "(", "obj", ",", "(", "str", ",", "bytes", ")", ")", "ex...
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] >>> >>>...
[ "Check", "if", "the", "object", "is", "a", "sequence", "of", "objects", ".", "String", "types", "are", "not", "included", "as", "sequences", "here", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/inference.py#L462-L491
19,503
pandas-dev/pandas
pandas/core/indexes/datetimes.py
date_range
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...
python
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", ",", "*"...
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 : ...
[ "Return", "a", "fixed", "frequency", "DatetimeIndex", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/datetimes.py#L1398-L1545
19,504
pandas-dev/pandas
pandas/core/indexes/datetimes.py
bdate_range
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...
python
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", ",", "h...
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...
[ "Return", "a", "fixed", "frequency", "DatetimeIndex", "with", "business", "day", "as", "the", "default", "frequency" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/datetimes.py#L1548-L1633
19,505
pandas-dev/pandas
pandas/core/indexes/datetimes.py
cdate_range
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 ...
python
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", ",", "*",...
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...
[ "Return", "a", "fixed", "frequency", "DatetimeIndex", "with", "CustomBusinessDay", "as", "the", "default", "frequency" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/datetimes.py#L1636-L1693
19,506
pandas-dev/pandas
pandas/core/window.py
_Window._create_blocks
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: ...
python
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", ")", ":", "obj", ",", "index", "=", "self", ".", "_convert_freq", "(", ")", "if", "index", "is", "not", "None", ":", "index", "=", "self", ".", "_on", "# filter out the on from the object", "if", "self", ".", "on", "...
Split data into blocks & return conformed data.
[ "Split", "data", "into", "blocks", "&", "return", "conformed", "data", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L99-L115
19,507
pandas-dev/pandas
pandas/core/window.py
_Window._get_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,...
python
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", ")", ":", "if", "self", ".", "is_freq_type", ":", "if", "index", "is", "None", ":", "index", "=", "self", ".", "_on", "return", "index", ",", "index", ".", "asi8", "return", "index", ",", ...
Return index as ndarrays. Returns ------- tuple of (index, index_as_ndarray)
[ "Return", "index", "as", "ndarrays", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L174-L187
19,508
pandas-dev/pandas
pandas/core/window.py
_Window._wrap_result
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: ...
python
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", ")", ":", "if", "obj", "is", "None", ":", "obj", "=", "self", ".", "_selected_obj", "index", "=", "obj", ".", "index", "if", "isinstance", "(", "...
Wrap a single result.
[ "Wrap", "a", "single", "result", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L219-L242
19,509
pandas-dev/pandas
pandas/core/window.py
_Window._wrap_results
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...
python
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", ")", ":", "from", "pandas", "import", "Series", ",", "concat", "from", "pandas", ".", "core", ".", "index", "import", "ensure_index", "final", "=", "[", "]", "for", "result",...
Wrap the results. Parameters ---------- results : list of ndarrays blocks : list of blocks obj : conformed data (may be resampled)
[ "Wrap", "the", "results", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L244-L288
19,510
pandas-dev/pandas
pandas/core/window.py
_Window._center_window
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...
python
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", ")", ":", "if", "self", ".", "axis", ">", "result", ".", "ndim", "-", "1", ":", "raise", "ValueError", "(", "\"Requested axis is larger then no. of argument \"", "\"dimensions\"", ")", "offset",...
Center the result in the window.
[ "Center", "the", "result", "in", "the", "window", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L290-L306
19,511
pandas-dev/pandas
pandas/core/window.py
Window._prep_window
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...
python
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", ")", ":", "window", "=", "self", ".", "_get_window", "(", ")", "if", "isinstance", "(", "window", ",", "(", "list", ",", "tuple", ",", "np", ".", "ndarray", ")", ")", ":", "return", "com"...
Provide validation for our window type, return the window we have already been validated.
[ "Provide", "validation", "for", "our", "window", "type", "return", "the", "window", "we", "have", "already", "been", "validated", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L609-L644
19,512
pandas-dev/pandas
pandas/core/window.py
Window._apply_window
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 ...
python
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", ")", ":", "window", "=", "self", ".", "_prep_window", "(", "*", "*", "kwargs", ")", "center", "=", "self", ".", "center", "blocks", ",", "obj", ",", "index", "=...
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
[ "Applies", "a", "moving", "window", "of", "type", "window_type", "on", "the", "data", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L646-L692
19,513
pandas-dev/pandas
pandas/core/window.py
_GroupByMixin._apply
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...
python
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", ")", ":", "def", "f", "(", "x", ",", "name", "=", "name", ",", "*", "args",...
Dispatch to apply; we are stripping all of the _apply kwargs and performing the original function call on the grouped object.
[ "Dispatch", "to", "apply", ";", "we", "are", "stripping", "all", "of", "the", "_apply", "kwargs", "and", "performing", "the", "original", "function", "call", "on", "the", "grouped", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L782-L797
19,514
pandas-dev/pandas
pandas/core/window.py
_Rolling._apply
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 ...
python
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", ")", ":", "if", "center", "is", "None", ":", "center", "=", "sel...
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() ...
[ "Rolling", "statistical", "measure", "using", "supplied", "function", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L806-L884
19,515
pandas-dev/pandas
pandas/core/window.py
Rolling._validate_monotonic
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))
python
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", ")", ":", "if", "not", "self", ".", "_on", ".", "is_monotonic", ":", "formatted", "=", "self", ".", "on", "or", "'index'", "raise", "ValueError", "(", "\"{0} must be \"", "\"monotonic\"", ".", "format", "(", "format...
Validate on is_monotonic.
[ "Validate", "on", "is_monotonic", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L1602-L1609
19,516
pandas-dev/pandas
pandas/core/window.py
Rolling._validate_freq
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 " ...
python
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", ")", ":", "from", "pandas", ".", "tseries", ".", "frequencies", "import", "to_offset", "try", ":", "return", "to_offset", "(", "self", ".", "window", ")", "except", "(", "TypeError", ",", "ValueError", ")", ":", "raise...
Validate & return window frequency.
[ "Validate", "&", "return", "window", "frequency", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L1611-L1621
19,517
pandas-dev/pandas
pandas/core/window.py
Expanding._get_window
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...
python
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", ")", ":", "axis", "=", "self", ".", "obj", ".", "_get_axis", "(", "self", ".", "axis", ")", "length", "=", "len", "(", "axis", ")", "+", "(", "other", "is", "not", "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 covariance. Returns ------- window :...
[ "Get", "the", "window", "length", "over", "which", "to", "perform", "some", "operation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L1888-L1907
19,518
pandas-dev/pandas
pandas/core/window.py
EWM._apply
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 ...
python
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", ")", ":", "blocks", ",", "obj", ",", "index", "=", "self", ".", "_create_blocks", "(", ")", "results", "=", "[", "]", "for", "b", "in", "blocks", ":", "try", ":", "values", "=", ...
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
[ "Rolling", "statistical", "measure", "using", "supplied", "function", ".", "Designed", "to", "be", "used", "with", "passed", "-", "in", "Cython", "array", "-", "based", "functions", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L2269-L2308
19,519
pandas-dev/pandas
pandas/core/window.py
EWM.mean
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'...
python
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", ")", ":", "nv", ".", "validate_window_func", "(", "'mean'", ",", "args", ",", "kwargs", ")", "return", "self", ".", "_apply", "(", "'ewma'", ",", "*", "*", "kwargs", ")" ]
Exponential weighted moving average. Parameters ---------- *args, **kwargs Arguments and keyword arguments to be passed into func.
[ "Exponential", "weighted", "moving", "average", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L2312-L2322
19,520
pandas-dev/pandas
pandas/core/window.py
EWM.std
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))
python
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", ")", ":", "nv", ".", "validate_window_func", "(", "'std'", ",", "args", ",", "kwargs", ")", "return", "_zsqrt", "(", "self", ".", "var", "(", "bias", ...
Exponential weighted moving stddev.
[ "Exponential", "weighted", "moving", "stddev", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L2327-L2332
19,521
pandas-dev/pandas
pandas/core/window.py
EWM.var
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...
python
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", ")", ":", "nv", ".", "validate_window_func", "(", "'var'", ",", "args", ",", "kwargs", ")", "def", "f", "(", "arg", ")", ":", "return", "libwindow", ...
Exponential weighted moving variance.
[ "Exponential", "weighted", "moving", "variance", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L2339-L2350
19,522
pandas-dev/pandas
pandas/core/window.py
EWM.cov
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...
python
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", ")", ":", "if", "other", "is", "None", ":", "other", "=", "self", ".", "_selected_obj", "# only default unset", "p...
Exponential weighted sample covariance.
[ "Exponential", "weighted", "sample", "covariance", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L2355-L2375
19,523
pandas-dev/pandas
pandas/core/window.py
EWM.corr
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...
python
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", ")", ":", "if", "other", "is", "None", ":", "other", "=", "self", ".", "_selected_obj", "# only default unset", "pairwise", "=", "True", "if",...
Exponential weighted sample correlation.
[ "Exponential", "weighted", "sample", "correlation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/window.py#L2380-L2410
19,524
pandas-dev/pandas
pandas/core/panel.py
_ensure_like_indices
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...
python
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", ")", ":", "n_time", "=", "len", "(", "time", ")", "n_panel", "=", "len", "(", "panels", ")", "u_panels", "=", "np", ".", "unique", "(", "panels", ")", "# this sorts!", "u_time", "=", "np", ".",...
Makes sure that time and panels are conformable.
[ "Makes", "sure", "that", "time", "and", "panels", "are", "conformable", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L45-L57
19,525
pandas-dev/pandas
pandas/core/panel.py
panel_index
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 ...
python
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", ")", ":", "if", "names", "is", "None", ":", "names", "=", "[", "'time'", ",", "'panel'", "]", "time", ",", "panels", "=", "_ensure_like_indices", "(", "time", ",", "panels", ...
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 --...
[ "Returns", "a", "multi", "-", "index", "suitable", "for", "a", "panel", "-", "like", "DataFrame", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L60-L101
19,526
pandas-dev/pandas
pandas/core/panel.py
Panel.from_dict
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...
python
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", ")", ":", "from", "collections", "import", "defaultdict", "orient", "=", "orient", ".", "lower", "(", ")", "if", "ori...
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 ...
[ "Construct", "Panel", "from", "dict", "of", "DataFrame", "objects", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L239-L279
19,527
pandas-dev/pandas
pandas/core/panel.py
Panel.to_excel
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...
python
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", ")", ":", "from", "pandas", ".", "io", ".", "excel", "import", "ExcelWriter", "if", "isinstance", "(", "path", ",", "str", "...
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...
[ "Write", "each", "DataFrame", "in", "Panel", "to", "a", "separate", "excel", "sheet", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L409-L458
19,528
pandas-dev/pandas
pandas/core/panel.py
Panel._unpickle_panel_compat
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) ...
python
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", "from", "pandas", ".", "io", ".", "pickle", "import", "_unpickle_array", "_unpickle", "=", "_unpickle_array", "vals", ",", "items", ",", "major", ",", "minor", "=", "st...
Unpickle the panel.
[ "Unpickle", "the", "panel", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L615-L629
19,529
pandas-dev/pandas
pandas/core/panel.py
Panel.conform
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 ...
python
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'", ")", ":", "axes", "=", "self", ".", "_get_plane_axes", "(", "axis", ")", "return", "frame", ".", "reindex", "(", "*", "*", "self", ".", "_extract_axes_for_slice", "(", "self", ",...
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...
[ "Conform", "input", "DataFrame", "to", "align", "with", "chosen", "axis", "pair", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L631-L649
19,530
pandas-dev/pandas
pandas/core/panel.py
Panel.round
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...
python
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", ")", ":", "nv", ".", "validate_round", "(", "args", ",", "kwargs", ")", "if", "is_integer", "(", "decimals", ")", ":", "result", "=", "np", ".", "a...
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...
[ "Round", "each", "value", "in", "Panel", "to", "a", "specified", "number", "of", "decimal", "places", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L657-L683
19,531
pandas-dev/pandas
pandas/core/panel.py
Panel.dropna
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 ...
python
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", ")", ":", "axis", "=", "self", ".", "_get_axis_number", "(", "axis", ")", "values", "=", "self", ".", "values", "mask", "=", "notna", "(", ...
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...
[ "Drop", "2D", "from", "panel", "holding", "passed", "axis", "constant", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L694-L733
19,532
pandas-dev/pandas
pandas/core/panel.py
Panel.xs
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 ----- ...
python
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", ")", ":", "axis", "=", "self", ".", "_get_axis_number", "(", "axis", ")", "if", "axis", "==", "0", ":", "return", "self", "[", "key", "]", "self", ".", "_consolidate_inplace", "(", ")", ...
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....
[ "Return", "slice", "of", "panel", "along", "selected", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L834-L866
19,533
pandas-dev/pandas
pandas/core/panel.py
Panel._apply_2d
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 ...
python
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", ")", ":", "ndim", "=", "self", ".", "ndim", "axis", "=", "[", "self", ".", "_get_axis_number", "(", "a", ")", "for", "a", "in", "axis", "]", "# construct slabs, in 2-d this is a DataFrame result", ...
Handle 2-d slices, equiv to iterating over the other axis.
[ "Handle", "2", "-", "d", "slices", "equiv", "to", "iterating", "over", "the", "other", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1115-L1139
19,534
pandas-dev/pandas
pandas/core/panel.py
Panel._construct_return_type
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(...
python
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", ")", ":", "ndim", "=", "getattr", "(", "result", ",", "'ndim'", ",", "None", ")", "# need to assume they are the same", "if", "ndim", "is", "None", ":", "if", "isinstance"...
Return the type for the ndim of the result.
[ "Return", "the", "type", "for", "the", "ndim", "of", "the", "result", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1173-L1207
19,535
pandas-dev/pandas
pandas/core/panel.py
Panel.count
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...
python
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'", ")", ":", "i", "=", "self", ".", "_get_axis_number", "(", "axis", ")", "values", "=", "self", ".", "values", "mask", "=", "np", ".", "isfinite", "(", "values", ")", "result", "=", "mask", "....
Return number of observations over requested axis. Parameters ---------- axis : {'items', 'major', 'minor'} or {0, 1, 2} Returns ------- count : DataFrame
[ "Return", "number", "of", "observations", "over", "requested", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1288-L1306
19,536
pandas-dev/pandas
pandas/core/panel.py
Panel.shift
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...
python
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'", ")", ":", "if", "freq", ":", "return", "self", ".", "tshift", "(", "periods", ",", "freq", ",", "axis", "=", "axis", ")", "return", "sup...
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...
[ "Shift", "index", "by", "desired", "number", "of", "periods", "with", "an", "optional", "time", "freq", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1308-L1330
19,537
pandas-dev/pandas
pandas/core/panel.py
Panel.join
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...
python
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", "=", "''", ")", ":", "from", "pandas", ".", "core", ".", "reshape", ".", "concat", "import", "concat", "if", "isinstance", "(", "other", ...
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. ...
[ "Join", "items", "with", "other", "Panel", "either", "on", "major", "and", "minor", "axes", "column", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1335-L1382
19,538
pandas-dev/pandas
pandas/core/panel.py
Panel.update
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...
python
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'", ")", ":", "if", "not", "isinstance", "(", "other", ",", "self", ".", "_constructor",...
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...
[ "Modify", "Panel", "in", "place", "using", "non", "-", "NA", "values", "from", "other", "Panel", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1386-L1426
19,539
pandas-dev/pandas
pandas/core/panel.py
Panel._extract_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)]
python
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", "[", "self", ".", "_extract_axis", "(", "self", ",", "data", ",", "axis", "=", "i", ",", "*", "*", "kwargs", ")", "for", "i", ",", "a", ...
Return a list of the axis indices.
[ "Return", "a", "list", "of", "the", "axis", "indices", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1443-L1448
19,540
pandas-dev/pandas
pandas/core/panel.py
Panel._extract_axes_for_slice
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)}
python
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", "{", "self", ".", "_AXIS_SLICEMAP", "[", "i", "]", ":", "a", "for", "i", ",", "a", "in", "zip", "(", "self", ".", "_AXIS_ORDERS", "[", "self", ".", "_AXIS_LEN", "-", "len...
Return the slice dictionary for these axes.
[ "Return", "the", "slice", "dictionary", "for", "these", "axes", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1451-L1456
19,541
pandas-dev/pandas
pandas/core/sorting.py
decons_obs_group_ids
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...
python
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", ")", ":", "if", "not", "xnull", ":", "lift", "=", "np", ".", "fromiter", "(", "(", "(", "a", "==", "-", "1", ")", ".", "any", "(", ")", "fo...
reconstruct labels from observed group ids Parameters ---------- xnull: boolean, if nulls are excluded; i.e. -1 labels are passed through
[ "reconstruct", "labels", "from", "observed", "group", "ids" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sorting.py#L151-L173
19,542
pandas-dev/pandas
pandas/core/computation/engines.py
_check_ne_builtin_clash
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...
python
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", ")", ":", "names", "=", "expr", ".", "names", "overlap", "=", "names", "&", "_ne_builtins", "if", "overlap", ":", "s", "=", "', '", ".", "join", "(", "map", "(", "repr", ",", "overlap", ")", ")", "raise", ...
Attempt to prevent foot-shooting in a helpful way. Parameters ---------- terms : Term Terms can contain
[ "Attempt", "to", "prevent", "foot", "-", "shooting", "in", "a", "helpful", "way", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/engines.py#L20-L35
19,543
pandas-dev/pandas
pandas/core/computation/engines.py
AbstractEngine.evaluate
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. ...
python
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", ")", ":", "if", "not", "self", ".", "_is_aligned", ":", "self", ".", "result_type", ",", "self", ".", "aligned_axes", "=", "_align", "(", "self", ".", "expr", ".", "terms", ")", "# make sure no names in resolvers and locals/glob...
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" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/engines.py#L55-L72
19,544
pandas-dev/pandas
pandas/core/internals/blocks.py
get_block_type
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 ...
python
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", ")", ":", "dtype", "=", "dtype", "or", "values", ".", "dtype", "vtype", "=", "dtype", ".", "type", "if", "is_sparse", "(", "dtype", ")", ":", "# Need this first(ish) so that Sparse[datetime] is...
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
[ "Find", "the", "appropriate", "Block", "subclass", "to", "use", "for", "the", "given", "values", "and", "dtype", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2987-L3030
19,545
pandas-dev/pandas
pandas/core/internals/blocks.py
_extend_blocks
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)...
python
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", ")", ":", "from", "pandas", ".", "core", ".", "internals", "import", "BlockManager", "if", "blocks", "is", "None", ":", "blocks", "=", "[", "]", "if", "isinstance", "(", "result", ",", ...
return a new extended blocks, givin the result
[ "return", "a", "new", "extended", "blocks", "givin", "the", "result" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L3060-L3075
19,546
pandas-dev/pandas
pandas/core/internals/blocks.py
_block_shape
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 ...
python
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", ")", ":", "if", "values", ".", "ndim", "<", "ndim", ":", "if", "shape", "is", "None", ":", "shape", "=", "values", ".", "shape", "if", "not", "is_extension_array_...
guarantee the shape of the values to be at least 1 d
[ "guarantee", "the", "shape", "of", "the", "values", "to", "be", "at", "least", "1", "d" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L3078-L3088
19,547
pandas-dev/pandas
pandas/core/internals/blocks.py
_putmask_smart
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 -...
python
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", ")", ":", "# 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...
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 ...
[ "Return", "a", "new", "ndarray", "try", "to", "preserve", "dtype", "if", "possible", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L3140-L3224
19,548
pandas-dev/pandas
pandas/core/internals/blocks.py
Block._check_ndim
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 ---------- ...
python
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", ")", ":", "if", "ndim", "is", "None", ":", "ndim", "=", "values", ".", "ndim", "if", "self", ".", "_validate_ndim", "and", "values", ".", "ndim", "!=", "ndim", ":", "msg", "=", "(", "\"...
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 ...
[ "ndim", "inference", "and", "validation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L87-L116
19,549
pandas-dev/pandas
pandas/core/internals/blocks.py
Block.is_categorical_astype
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...
python
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", ")", ":", "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} ...
validate that we have a astypeable to categorical, returns a boolean if we are a categorical
[ "validate", "that", "we", "have", "a", "astypeable", "to", "categorical", "returns", "a", "boolean", "if", "we", "are", "a", "categorical" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L145-L158
19,550
pandas-dev/pandas
pandas/core/internals/blocks.py
Block.get_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
python
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", ")", ":", "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
[ "return", "an", "internal", "format", "currently", "just", "the", "ndarray", "this", "is", "often", "overridden", "to", "handle", "to_dense", "like", "operations" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L174-L181
19,551
pandas-dev/pandas
pandas/core/internals/blocks.py
Block.make_block
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...
python
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", ")", ":", "if", "placement", "is", "None", ":", "placement", "=", "self", ".", "mgr_locs", "if", "ndim", "is", "None", ":", "ndim", "=", "self",...
Create a new block, with type inference propagate any values that are not specified
[ "Create", "a", "new", "block", "with", "type", "inference", "propagate", "any", "values", "that", "are", "not", "specified" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L212-L222
19,552
pandas-dev/pandas
pandas/core/internals/blocks.py
Block.make_block_same_class
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...
python
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", ")", ":", "if", "dtype", "is", "not", "None", ":", "# issue 19431 fastparquet is passing this", "warnings", ".", "...
Wrap given values in a block of same type as self.
[ "Wrap", "given", "values", "in", "a", "block", "of", "same", "type", "as", "self", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L224-L234
19,553
pandas-dev/pandas
pandas/core/internals/blocks.py
Block.apply
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...
python
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", ")", ":", "with", "np", ".", "errstate", "(", "all", "=", "'ignore'", ")", ":", "result", "=", "func", "(", "self", ".", "values", ",", "*", "*", "kwargs", ")", "if", "not", "is...
apply the function to my values; return a block if we are not one
[ "apply", "the", "function", "to", "my", "values", ";", "return", "a", "block", "if", "we", "are", "not", "one" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L337-L347
19,554
pandas-dev/pandas
pandas/core/internals/blocks.py
Block.fillna
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: ...
python
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", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "if", "not", "self", ".", "_can_h...
fillna on the block with the value. If we fail, then convert to ObjectBlock and try again
[ "fillna", "on", "the", "block", "with", "the", "value", ".", "If", "we", "fail", "then", "convert", "to", "ObjectBlock", "and", "try", "again" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L349-L397
19,555
pandas-dev/pandas
pandas/core/internals/blocks.py
Block.split_and_operate
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 : ...
python
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", ")", ":", "if", "mask", "is", "None", ":", "mask", "=", "np", ".", "ones", "(", "self", ".", "shape", ",", "dtype", "=", "bool", ")", "new_values", "=", "self", ".", ...
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 : ...
[ "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", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L399-L460
19,556
pandas-dev/pandas
pandas/core/internals/blocks.py
Block.downcast
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...
python
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", ")", ":", "# turn it off completely", "if", "dtypes", "is", "False", ":", "return", "self", "values", "=", "self", ".", "values", "# single block handling", "if", "self", ".", "_is_single_block", ":",...
try to downcast each item to the dict of dtypes if present
[ "try", "to", "downcast", "each", "item", "to", "the", "dict", "of", "dtypes", "if", "present" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L475-L515
19,557
pandas-dev/pandas
pandas/core/internals/blocks.py
Block._can_hold_element
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)
python
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", ")", ":", "dtype", "=", "self", ".", "values", ".", "dtype", ".", "type", "tipo", "=", "maybe_infer_dtype_type", "(", "element", ")", "if", "tipo", "is", "not", "None", ":", "return", "issubclass", ...
require the same dtype as ourselves
[ "require", "the", "same", "dtype", "as", "ourselves" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L643-L649
19,558
pandas-dev/pandas
pandas/core/internals/blocks.py
Block._try_cast_result
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 ...
python
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", ")", ":", "if", "dtype", "is", "None", ":", "dtype", "=", "self", ".", "dtype", "if", "self", ".", "is_integer", "or", "self", ".", "is_bool", "or", "self", ".", "is_da...
try to cast the result to our original type, we may have roundtripped thru object in the mean-time
[ "try", "to", "cast", "the", "result", "to", "our", "original", "type", "we", "may", "have", "roundtripped", "thru", "object", "in", "the", "mean", "-", "time" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L651-L682
19,559
pandas-dev/pandas
pandas/core/internals/blocks.py
Block.replace
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...
python
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", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'i...
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.
[ "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", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L731-L769
19,560
pandas-dev/pandas
pandas/core/internals/blocks.py
Block.setitem
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...
python
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", ")", ":", "# coerce None values, if appropriate", "if", "value", "is", "None", ":", "if", "self", ".", "is_numeric", ":", "value", "=", "np", ".", "nan", "# coerce if block dtype can store value", "val...
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...
[ "Set", "the", "value", "inplace", "returning", "a", "a", "maybe", "different", "typed", "block", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L775-L900
19,561
pandas-dev/pandas
pandas/core/internals/blocks.py
Block.putmask
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...
python
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", ")", ":", "new_values", "=", "self", ".", "values", "if", "inplace", "else", "se...
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 ...
[ "putmask", "the", "data", "to", "the", "block", ";", "it", "is", "possible", "that", "we", "may", "create", "a", "new", "dtype", "of", "block" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L902-L1012
19,562
pandas-dev/pandas
pandas/core/internals/blocks.py
Block.coerce_to_target_dtype
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...
python
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", ")", ":", "# if we cannot then coerce to object", "dtype", ",", "_", "=", "infer_dtype_from", "(", "other", ",", "pandas_dtype", "=", "True", ")", "if", "is_dtype_equal", "(", "self", ".", "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
[ "coerce", "the", "current", "block", "to", "a", "dtype", "compat", "for", "other", "we", "will", "return", "a", "block", "possibly", "object", "and", "not", "raise" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1014-L1073
19,563
pandas-dev/pandas
pandas/core/internals/blocks.py
Block._interpolate_with_fill
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') # ...
python
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
[ "fillna", "but", "using", "the", "interpolate", "machinery" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1119-L1143
19,564
pandas-dev/pandas
pandas/core/internals/blocks.py
Block._interpolate
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...
python
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'", ",", "l...
interpolate using scipy wrappers
[ "interpolate", "using", "scipy", "wrappers" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1145-L1184
19,565
pandas-dev/pandas
pandas/core/internals/blocks.py
Block.take_nd
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,...
python
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", ")", ":", "# algos.take_nd dispatches for DatetimeTZBlock, CategoricalBlock", "# so need to preserve types", "# sparse is treated like an ndarray, but...
Take values according to indexer and return them as a block.bb
[ "Take", "values", "according", "to", "indexer", "and", "return", "them", "as", "a", "block", ".", "bb" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1186-L1222
19,566
pandas-dev/pandas
pandas/core/internals/blocks.py
Block.diff
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)]
python
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", ")", ":", "new_values", "=", "algos", ".", "diff", "(", "self", ".", "values", ",", "n", ",", "axis", "=", "axis", ")", "return", "[", "self", ".", "make_block", "(", "values", "=", "...
return block for the diff of the values
[ "return", "block", "for", "the", "diff", "of", "the", "values" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1224-L1227
19,567
pandas-dev/pandas
pandas/core/internals/blocks.py
Block.shift
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 ...
python
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", ")", ":", "# convert integer to float if necessary. need to do a lot more than", "# that, handle boolean etc also", "new_values", ",", "fill_value", "=", "maybe_upcast", ...
shift the block by periods, possibly upcast
[ "shift", "the", "block", "by", "periods", "possibly", "upcast" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1229-L1257
19,568
pandas-dev/pandas
pandas/core/internals/blocks.py
Block._unstack
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. ...
python
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", ")", ":", "unstacker", "=", "unstacker_func", "(", "self", ".", "values", ".", "T", ")", "new_items", "=", "unstacker", ".", "get_new_columns", "(", ...
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...
[ "Return", "a", "list", "of", "unstacked", "blocks", "of", "self" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1372-L1403
19,569
pandas-dev/pandas
pandas/core/internals/blocks.py
Block.quantile
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...
python
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", ")", ":", "if", "self", ".", "is_datetimetz", ":", "# TODO: cleanup this special case.", "# We need to operate on i8 values for datetimetz", "# but `Block.get_values...
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
[ "compute", "the", "quantiles", "of", "the" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1405-L1472
19,570
pandas-dev/pandas
pandas/core/internals/blocks.py
NonConsolidatableMixIn.putmask
def putmask(self, mask, new, align=True, inplace=False, axis=0, transpose=False): """ putmask the data to the block; we must be a single block and not generate other blocks return the resulting block Parameters ---------- mask : the condition to...
python
def putmask(self, mask, new, align=True, inplace=False, axis=0, transpose=False): """ putmask the data to the block; we must be a single block and not generate other blocks return the resulting block Parameters ---------- mask : the condition to...
[ "def", "putmask", "(", "self", ",", "mask", ",", "new", ",", "align", "=", "True", ",", "inplace", "=", "False", ",", "axis", "=", "0", ",", "transpose", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ...
putmask the data to the block; we must be a single block and not generate other blocks return the resulting block Parameters ---------- mask : the condition to respect new : a ndarray/object align : boolean, perform alignment on other/cond, default is True ...
[ "putmask", "the", "data", "to", "the", "block", ";", "we", "must", "be", "a", "single", "block", "and", "not", "generate", "other", "blocks" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1564-L1597
19,571
pandas-dev/pandas
pandas/core/internals/blocks.py
NonConsolidatableMixIn._get_unstack_items
def _get_unstack_items(self, unstacker, new_columns): """ Get the placement, values, and mask for a Block unstack. This is shared between ObjectBlock and ExtensionBlock. They differ in that ObjectBlock passes the values, while ExtensionBlock passes the dummy ndarray of positions...
python
def _get_unstack_items(self, unstacker, new_columns): """ Get the placement, values, and mask for a Block unstack. This is shared between ObjectBlock and ExtensionBlock. They differ in that ObjectBlock passes the values, while ExtensionBlock passes the dummy ndarray of positions...
[ "def", "_get_unstack_items", "(", "self", ",", "unstacker", ",", "new_columns", ")", ":", "# shared with ExtensionBlock", "new_items", "=", "unstacker", ".", "get_new_columns", "(", ")", "new_placement", "=", "new_columns", ".", "get_indexer", "(", "new_items", ")",...
Get the placement, values, and mask for a Block unstack. This is shared between ObjectBlock and ExtensionBlock. They differ in that ObjectBlock passes the values, while ExtensionBlock passes the dummy ndarray of positions to be used by a take later. Parameters ---------...
[ "Get", "the", "placement", "values", "and", "mask", "for", "a", "Block", "unstack", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1602-L1632
19,572
pandas-dev/pandas
pandas/core/internals/blocks.py
ExtensionBlock._maybe_coerce_values
def _maybe_coerce_values(self, values): """Unbox to an extension array. This will unbox an ExtensionArray stored in an Index or Series. ExtensionArrays pass through. No dtype coercion is done. Parameters ---------- values : Index, Series, ExtensionArray Returns...
python
def _maybe_coerce_values(self, values): """Unbox to an extension array. This will unbox an ExtensionArray stored in an Index or Series. ExtensionArrays pass through. No dtype coercion is done. Parameters ---------- values : Index, Series, ExtensionArray Returns...
[ "def", "_maybe_coerce_values", "(", "self", ",", "values", ")", ":", "if", "isinstance", "(", "values", ",", "(", "ABCIndexClass", ",", "ABCSeries", ")", ")", ":", "values", "=", "values", ".", "_values", "return", "values" ]
Unbox to an extension array. This will unbox an ExtensionArray stored in an Index or Series. ExtensionArrays pass through. No dtype coercion is done. Parameters ---------- values : Index, Series, ExtensionArray Returns ------- ExtensionArray
[ "Unbox", "to", "an", "extension", "array", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1651-L1667
19,573
pandas-dev/pandas
pandas/core/internals/blocks.py
ExtensionBlock.setitem
def setitem(self, indexer, value): """Set the value inplace, returning a same-typed block. This differs from Block.setitem by not allowing setitem to change the dtype of the Block. Parameters ---------- indexer : tuple, list-like, array-like, slice The subse...
python
def setitem(self, indexer, value): """Set the value inplace, returning a same-typed block. This differs from Block.setitem by not allowing setitem to change the dtype of the Block. Parameters ---------- indexer : tuple, list-like, array-like, slice The subse...
[ "def", "setitem", "(", "self", ",", "indexer", ",", "value", ")", ":", "if", "isinstance", "(", "indexer", ",", "tuple", ")", ":", "# we are always 1-D", "indexer", "=", "indexer", "[", "0", "]", "check_setitem_lengths", "(", "indexer", ",", "value", ",", ...
Set the value inplace, returning a same-typed block. This differs from Block.setitem by not allowing setitem to change the dtype of the Block. Parameters ---------- indexer : tuple, list-like, array-like, slice The subset of self.values to set value : object...
[ "Set", "the", "value", "inplace", "returning", "a", "same", "-", "typed", "block", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1693-L1721
19,574
pandas-dev/pandas
pandas/core/internals/blocks.py
ExtensionBlock.take_nd
def take_nd(self, indexer, axis=0, new_mgr_locs=None, fill_tuple=None): """ Take values according to indexer and return them as a block. """ if fill_tuple is None: fill_value = None else: fill_value = fill_tuple[0] # axis doesn't matter; we are re...
python
def take_nd(self, indexer, axis=0, new_mgr_locs=None, fill_tuple=None): """ Take values according to indexer and return them as a block. """ if fill_tuple is None: fill_value = None else: fill_value = fill_tuple[0] # axis doesn't matter; we are re...
[ "def", "take_nd", "(", "self", ",", "indexer", ",", "axis", "=", "0", ",", "new_mgr_locs", "=", "None", ",", "fill_tuple", "=", "None", ")", ":", "if", "fill_tuple", "is", "None", ":", "fill_value", "=", "None", "else", ":", "fill_value", "=", "fill_tu...
Take values according to indexer and return them as a block.
[ "Take", "values", "according", "to", "indexer", "and", "return", "them", "as", "a", "block", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1733-L1754
19,575
pandas-dev/pandas
pandas/core/internals/blocks.py
ExtensionBlock.shift
def shift(self, periods: int, axis: libinternals.BlockPlacement = 0, fill_value: Any = None) -> List['ExtensionBlock']: """ Shift the block by `periods`. Dispatches to underlying ExtensionArray and re-boxes in an ExtensionBlock. """ ...
python
def shift(self, periods: int, axis: libinternals.BlockPlacement = 0, fill_value: Any = None) -> List['ExtensionBlock']: """ Shift the block by `periods`. Dispatches to underlying ExtensionArray and re-boxes in an ExtensionBlock. """ ...
[ "def", "shift", "(", "self", ",", "periods", ":", "int", ",", "axis", ":", "libinternals", ".", "BlockPlacement", "=", "0", ",", "fill_value", ":", "Any", "=", "None", ")", "->", "List", "[", "'ExtensionBlock'", "]", ":", "return", "[", "self", ".", ...
Shift the block by `periods`. Dispatches to underlying ExtensionArray and re-boxes in an ExtensionBlock.
[ "Shift", "the", "block", "by", "periods", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1816-L1830
19,576
pandas-dev/pandas
pandas/core/internals/blocks.py
DatetimeBlock._astype
def _astype(self, dtype, **kwargs): """ these automatically copy, so copy=True has no effect raise on an except if raise == True """ dtype = pandas_dtype(dtype) # if we are passed a datetime64[ns, tz] if is_datetime64tz_dtype(dtype): values = self.val...
python
def _astype(self, dtype, **kwargs): """ these automatically copy, so copy=True has no effect raise on an except if raise == True """ dtype = pandas_dtype(dtype) # if we are passed a datetime64[ns, tz] if is_datetime64tz_dtype(dtype): values = self.val...
[ "def", "_astype", "(", "self", ",", "dtype", ",", "*", "*", "kwargs", ")", ":", "dtype", "=", "pandas_dtype", "(", "dtype", ")", "# if we are passed a datetime64[ns, tz]", "if", "is_datetime64tz_dtype", "(", "dtype", ")", ":", "values", "=", "self", ".", "va...
these automatically copy, so copy=True has no effect raise on an except if raise == True
[ "these", "automatically", "copy", "so", "copy", "=", "True", "has", "no", "effect", "raise", "on", "an", "except", "if", "raise", "==", "True" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2084-L2100
19,577
pandas-dev/pandas
pandas/core/internals/blocks.py
DatetimeBlock._try_coerce_args
def _try_coerce_args(self, values, other): """ Coerce values and other to dtype 'i8'. NaN and NaT convert to the smallest i8, and will correctly round-trip to NaT if converted back in _try_coerce_result. values is always ndarray-like, other may not be Parameters ...
python
def _try_coerce_args(self, values, other): """ Coerce values and other to dtype 'i8'. NaN and NaT convert to the smallest i8, and will correctly round-trip to NaT if converted back in _try_coerce_result. values is always ndarray-like, other may not be Parameters ...
[ "def", "_try_coerce_args", "(", "self", ",", "values", ",", "other", ")", ":", "values", "=", "values", ".", "view", "(", "'i8'", ")", "if", "isinstance", "(", "other", ",", "bool", ")", ":", "raise", "TypeError", "elif", "is_null_datetimelike", "(", "ot...
Coerce values and other to dtype 'i8'. NaN and NaT convert to the smallest i8, and will correctly round-trip to NaT if converted back in _try_coerce_result. values is always ndarray-like, other may not be Parameters ---------- values : ndarray-like other : ndarra...
[ "Coerce", "values", "and", "other", "to", "dtype", "i8", ".", "NaN", "and", "NaT", "convert", "to", "the", "smallest", "i8", "and", "will", "correctly", "round", "-", "trip", "to", "NaT", "if", "converted", "back", "in", "_try_coerce_result", ".", "values"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2109-L2145
19,578
pandas-dev/pandas
pandas/core/internals/blocks.py
DatetimeTZBlock.get_values
def get_values(self, dtype=None): """ Returns an ndarray of values. Parameters ---------- dtype : np.dtype Only `object`-like dtypes are respected here (not sure why). Returns ------- values : ndarray When ``dtype=obje...
python
def get_values(self, dtype=None): """ Returns an ndarray of values. Parameters ---------- dtype : np.dtype Only `object`-like dtypes are respected here (not sure why). Returns ------- values : ndarray When ``dtype=obje...
[ "def", "get_values", "(", "self", ",", "dtype", "=", "None", ")", ":", "values", "=", "self", ".", "values", "if", "is_object_dtype", "(", "dtype", ")", ":", "values", "=", "values", ".", "_box_values", "(", "values", ".", "_data", ")", "values", "=", ...
Returns an ndarray of values. Parameters ---------- dtype : np.dtype Only `object`-like dtypes are respected here (not sure why). Returns ------- values : ndarray When ``dtype=object``, then and object-dtype ndarray of box...
[ "Returns", "an", "ndarray", "of", "values", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2245-L2277
19,579
pandas-dev/pandas
pandas/core/internals/blocks.py
DatetimeTZBlock._try_coerce_args
def _try_coerce_args(self, values, other): """ localize and return i8 for the values Parameters ---------- values : ndarray-like other : ndarray-like or scalar Returns ------- base-type values, base-type other """ # asi8 is a view...
python
def _try_coerce_args(self, values, other): """ localize and return i8 for the values Parameters ---------- values : ndarray-like other : ndarray-like or scalar Returns ------- base-type values, base-type other """ # asi8 is a view...
[ "def", "_try_coerce_args", "(", "self", ",", "values", ",", "other", ")", ":", "# asi8 is a view, needs copy", "values", "=", "_block_shape", "(", "values", ".", "view", "(", "\"i8\"", ")", ",", "ndim", "=", "self", ".", "ndim", ")", "if", "isinstance", "(...
localize and return i8 for the values Parameters ---------- values : ndarray-like other : ndarray-like or scalar Returns ------- base-type values, base-type other
[ "localize", "and", "return", "i8", "for", "the", "values" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2294-L2336
19,580
pandas-dev/pandas
pandas/core/internals/blocks.py
DatetimeTZBlock.diff
def diff(self, n, axis=0): """1st discrete difference Parameters ---------- n : int, number of periods to diff axis : int, axis to diff upon. default 0 Return ------ A list with a new TimeDeltaBlock. Note ---- The arguments here ...
python
def diff(self, n, axis=0): """1st discrete difference Parameters ---------- n : int, number of periods to diff axis : int, axis to diff upon. default 0 Return ------ A list with a new TimeDeltaBlock. Note ---- The arguments here ...
[ "def", "diff", "(", "self", ",", "n", ",", "axis", "=", "0", ")", ":", "if", "axis", "==", "0", ":", "# Cannot currently calculate diff across multiple blocks since this", "# function is invoked via apply", "raise", "NotImplementedError", "new_values", "=", "(", "self...
1st discrete difference Parameters ---------- n : int, number of periods to diff axis : int, axis to diff upon. default 0 Return ------ A list with a new TimeDeltaBlock. Note ---- The arguments here are mimicking shift so they are called...
[ "1st", "discrete", "difference" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2362-L2388
19,581
pandas-dev/pandas
pandas/core/internals/blocks.py
TimeDeltaBlock._try_coerce_args
def _try_coerce_args(self, values, other): """ Coerce values and other to int64, with null values converted to iNaT. values is always ndarray-like, other may not be Parameters ---------- values : ndarray-like other : ndarray-like or scalar Returns ...
python
def _try_coerce_args(self, values, other): """ Coerce values and other to int64, with null values converted to iNaT. values is always ndarray-like, other may not be Parameters ---------- values : ndarray-like other : ndarray-like or scalar Returns ...
[ "def", "_try_coerce_args", "(", "self", ",", "values", ",", "other", ")", ":", "values", "=", "values", ".", "view", "(", "'i8'", ")", "if", "isinstance", "(", "other", ",", "bool", ")", ":", "raise", "TypeError", "elif", "is_null_datetimelike", "(", "ot...
Coerce values and other to int64, with null values converted to iNaT. values is always ndarray-like, other may not be Parameters ---------- values : ndarray-like other : ndarray-like or scalar Returns ------- base-type values, base-type other
[ "Coerce", "values", "and", "other", "to", "int64", "with", "null", "values", "converted", "to", "iNaT", ".", "values", "is", "always", "ndarray", "-", "like", "other", "may", "not", "be" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2477-L2506
19,582
pandas-dev/pandas
pandas/core/internals/blocks.py
ObjectBlock._replace_single
def _replace_single(self, to_replace, value, inplace=False, filter=None, regex=False, convert=True, mask=None): """ Replace elements by the given value. Parameters ---------- to_replace : object or pattern Scalar to replace or regular expressi...
python
def _replace_single(self, to_replace, value, inplace=False, filter=None, regex=False, convert=True, mask=None): """ Replace elements by the given value. Parameters ---------- to_replace : object or pattern Scalar to replace or regular expressi...
[ "def", "_replace_single", "(", "self", ",", "to_replace", ",", "value", ",", "inplace", "=", "False", ",", "filter", "=", "None", ",", "regex", "=", "False", ",", "convert", "=", "True", ",", "mask", "=", "None", ")", ":", "inplace", "=", "validate_boo...
Replace elements by the given value. Parameters ---------- to_replace : object or pattern Scalar to replace or regular expression to match. value : object Replacement object. inplace : bool, default False Perform inplace modification. ...
[ "Replace", "elements", "by", "the", "given", "value", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2744-L2841
19,583
pandas-dev/pandas
pandas/io/excel/_xlsxwriter.py
_XlsxStyler.convert
def convert(cls, style_dict, num_format_str=None): """ converts a style_dict to an xlsxwriter format dict Parameters ---------- style_dict : style dictionary to convert num_format_str : optional number format string """ # Create a XlsxWriter format objec...
python
def convert(cls, style_dict, num_format_str=None): """ converts a style_dict to an xlsxwriter format dict Parameters ---------- style_dict : style dictionary to convert num_format_str : optional number format string """ # Create a XlsxWriter format objec...
[ "def", "convert", "(", "cls", ",", "style_dict", ",", "num_format_str", "=", "None", ")", ":", "# Create a XlsxWriter format object.", "props", "=", "{", "}", "if", "num_format_str", "is", "not", "None", ":", "props", "[", "'num_format'", "]", "=", "num_format...
converts a style_dict to an xlsxwriter format dict Parameters ---------- style_dict : style dictionary to convert num_format_str : optional number format string
[ "converts", "a", "style_dict", "to", "an", "xlsxwriter", "format", "dict" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_xlsxwriter.py#L85-L147
19,584
pandas-dev/pandas
pandas/core/reshape/reshape.py
_unstack_extension_series
def _unstack_extension_series(series, level, fill_value): """ Unstack an ExtensionArray-backed Series. The ExtensionDtype is preserved. Parameters ---------- series : Series A Series with an ExtensionArray for values level : Any The level name or number. fill_value : An...
python
def _unstack_extension_series(series, level, fill_value): """ Unstack an ExtensionArray-backed Series. The ExtensionDtype is preserved. Parameters ---------- series : Series A Series with an ExtensionArray for values level : Any The level name or number. fill_value : An...
[ "def", "_unstack_extension_series", "(", "series", ",", "level", ",", "fill_value", ")", ":", "# Implementation note: the basic idea is to", "# 1. Do a regular unstack on a dummy array of integers", "# 2. Followup with a columnwise take.", "# We use the dummy take to discover newly-created...
Unstack an ExtensionArray-backed Series. The ExtensionDtype is preserved. Parameters ---------- series : Series A Series with an ExtensionArray for values level : Any The level name or number. fill_value : Any The user-level (not physical storage) fill value to use for ...
[ "Unstack", "an", "ExtensionArray", "-", "backed", "Series", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/reshape.py#L411-L454
19,585
pandas-dev/pandas
pandas/core/reshape/reshape.py
stack
def stack(frame, level=-1, dropna=True): """ Convert DataFrame to Series with multi-level Index. Columns become the second level of the resulting hierarchical index Returns ------- stacked : Series """ def factorize(index): if index.is_unique: return index, np.arange...
python
def stack(frame, level=-1, dropna=True): """ Convert DataFrame to Series with multi-level Index. Columns become the second level of the resulting hierarchical index Returns ------- stacked : Series """ def factorize(index): if index.is_unique: return index, np.arange...
[ "def", "stack", "(", "frame", ",", "level", "=", "-", "1", ",", "dropna", "=", "True", ")", ":", "def", "factorize", "(", "index", ")", ":", "if", "index", ".", "is_unique", ":", "return", "index", ",", "np", ".", "arange", "(", "len", "(", "inde...
Convert DataFrame to Series with multi-level Index. Columns become the second level of the resulting hierarchical index Returns ------- stacked : Series
[ "Convert", "DataFrame", "to", "Series", "with", "multi", "-", "level", "Index", ".", "Columns", "become", "the", "second", "level", "of", "the", "resulting", "hierarchical", "index" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/reshape.py#L457-L524
19,586
pandas-dev/pandas
pandas/core/reshape/reshape.py
make_axis_dummies
def make_axis_dummies(frame, axis='minor', transform=None): """ Construct 1-0 dummy variables corresponding to designated axis labels Parameters ---------- frame : DataFrame axis : {'major', 'minor'}, default 'minor' transform : function, default None Function to apply to axis l...
python
def make_axis_dummies(frame, axis='minor', transform=None): """ Construct 1-0 dummy variables corresponding to designated axis labels Parameters ---------- frame : DataFrame axis : {'major', 'minor'}, default 'minor' transform : function, default None Function to apply to axis l...
[ "def", "make_axis_dummies", "(", "frame", ",", "axis", "=", "'minor'", ",", "transform", "=", "None", ")", ":", "numbers", "=", "{", "'major'", ":", "0", ",", "'minor'", ":", "1", "}", "num", "=", "numbers", ".", "get", "(", "axis", ",", "axis", ")...
Construct 1-0 dummy variables corresponding to designated axis labels Parameters ---------- frame : DataFrame axis : {'major', 'minor'}, default 'minor' transform : function, default None Function to apply to axis labels first. For example, to get "day of week" dummies in a time...
[ "Construct", "1", "-", "0", "dummy", "variables", "corresponding", "to", "designated", "axis", "labels" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/reshape.py#L970-L1003
19,587
pandas-dev/pandas
pandas/core/reshape/reshape.py
_reorder_for_extension_array_stack
def _reorder_for_extension_array_stack(arr, n_rows, n_columns): """ Re-orders the values when stacking multiple extension-arrays. The indirect stacking method used for EAs requires a followup take to get the order correct. Parameters ---------- arr : ExtensionArray n_rows, n_columns : ...
python
def _reorder_for_extension_array_stack(arr, n_rows, n_columns): """ Re-orders the values when stacking multiple extension-arrays. The indirect stacking method used for EAs requires a followup take to get the order correct. Parameters ---------- arr : ExtensionArray n_rows, n_columns : ...
[ "def", "_reorder_for_extension_array_stack", "(", "arr", ",", "n_rows", ",", "n_columns", ")", ":", "# final take to get the order correct.", "# idx is an indexer like", "# [c0r0, c1r0, c2r0, ...,", "# c0r1, c1r1, c2r1, ...]", "idx", "=", "np", ".", "arange", "(", "n_rows", ...
Re-orders the values when stacking multiple extension-arrays. The indirect stacking method used for EAs requires a followup take to get the order correct. Parameters ---------- arr : ExtensionArray n_rows, n_columns : int The number of rows and columns in the original DataFrame. R...
[ "Re", "-", "orders", "the", "values", "when", "stacking", "multiple", "extension", "-", "arrays", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/reshape.py#L1006-L1038
19,588
pandas-dev/pandas
pandas/io/sas/sas_xport.py
_parse_float_vec
def _parse_float_vec(vec): """ Parse a vector of float values representing IBM 8 byte floats into native 8 byte floats. """ dtype = np.dtype('>u4,>u4') vec1 = vec.view(dtype=dtype) xport1 = vec1['f0'] xport2 = vec1['f1'] # Start by setting first half of ieee number to first half of...
python
def _parse_float_vec(vec): """ Parse a vector of float values representing IBM 8 byte floats into native 8 byte floats. """ dtype = np.dtype('>u4,>u4') vec1 = vec.view(dtype=dtype) xport1 = vec1['f0'] xport2 = vec1['f1'] # Start by setting first half of ieee number to first half of...
[ "def", "_parse_float_vec", "(", "vec", ")", ":", "dtype", "=", "np", ".", "dtype", "(", "'>u4,>u4'", ")", "vec1", "=", "vec", ".", "view", "(", "dtype", "=", "dtype", ")", "xport1", "=", "vec1", "[", "'f0'", "]", "xport2", "=", "vec1", "[", "'f1'",...
Parse a vector of float values representing IBM 8 byte floats into native 8 byte floats.
[ "Parse", "a", "vector", "of", "float", "values", "representing", "IBM", "8", "byte", "floats", "into", "native", "8", "byte", "floats", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sas/sas_xport.py#L170-L224
19,589
pandas-dev/pandas
pandas/io/sas/sas_xport.py
XportReader._record_count
def _record_count(self): """ Get number of records in file. This is maybe suboptimal because we have to seek to the end of the file. Side effect: returns file position to record_start. """ self.filepath_or_buffer.seek(0, 2) total_records_length = (self....
python
def _record_count(self): """ Get number of records in file. This is maybe suboptimal because we have to seek to the end of the file. Side effect: returns file position to record_start. """ self.filepath_or_buffer.seek(0, 2) total_records_length = (self....
[ "def", "_record_count", "(", "self", ")", ":", "self", ".", "filepath_or_buffer", ".", "seek", "(", "0", ",", "2", ")", "total_records_length", "=", "(", "self", ".", "filepath_or_buffer", ".", "tell", "(", ")", "-", "self", ".", "record_start", ")", "if...
Get number of records in file. This is maybe suboptimal because we have to seek to the end of the file. Side effect: returns file position to record_start.
[ "Get", "number", "of", "records", "in", "file", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sas/sas_xport.py#L364-L399
19,590
pandas-dev/pandas
pandas/io/sas/sas_xport.py
XportReader.get_chunk
def get_chunk(self, size=None): """ Reads lines from Xport file and returns as dataframe Parameters ---------- size : int, defaults to None Number of lines to read. If None, reads whole file. Returns ------- DataFrame """ if ...
python
def get_chunk(self, size=None): """ Reads lines from Xport file and returns as dataframe Parameters ---------- size : int, defaults to None Number of lines to read. If None, reads whole file. Returns ------- DataFrame """ if ...
[ "def", "get_chunk", "(", "self", ",", "size", "=", "None", ")", ":", "if", "size", "is", "None", ":", "size", "=", "self", ".", "_chunksize", "return", "self", ".", "read", "(", "nrows", "=", "size", ")" ]
Reads lines from Xport file and returns as dataframe Parameters ---------- size : int, defaults to None Number of lines to read. If None, reads whole file. Returns ------- DataFrame
[ "Reads", "lines", "from", "Xport", "file", "and", "returns", "as", "dataframe" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sas/sas_xport.py#L401-L416
19,591
pandas-dev/pandas
pandas/core/internals/managers.py
construction_error
def construction_error(tot_items, block_shape, axes, e=None): """ raise a helpful message about our construction """ passed = tuple(map(int, [tot_items] + list(block_shape))) # Correcting the user facing error message during dataframe construction if len(passed) <= 2: passed = passed[::-1] ...
python
def construction_error(tot_items, block_shape, axes, e=None): """ raise a helpful message about our construction """ passed = tuple(map(int, [tot_items] + list(block_shape))) # Correcting the user facing error message during dataframe construction if len(passed) <= 2: passed = passed[::-1] ...
[ "def", "construction_error", "(", "tot_items", ",", "block_shape", ",", "axes", ",", "e", "=", "None", ")", ":", "passed", "=", "tuple", "(", "map", "(", "int", ",", "[", "tot_items", "]", "+", "list", "(", "block_shape", ")", ")", ")", "# Correcting t...
raise a helpful message about our construction
[ "raise", "a", "helpful", "message", "about", "our", "construction" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1670-L1687
19,592
pandas-dev/pandas
pandas/core/internals/managers.py
_simple_blockify
def _simple_blockify(tuples, dtype): """ return a single array of a block that has a single dtype; if dtype is not None, coerce to this dtype """ values, placement = _stack_arrays(tuples, dtype) # CHECK DTYPE? if dtype is not None and values.dtype != dtype: # pragma: no cover values = ...
python
def _simple_blockify(tuples, dtype): """ return a single array of a block that has a single dtype; if dtype is not None, coerce to this dtype """ values, placement = _stack_arrays(tuples, dtype) # CHECK DTYPE? if dtype is not None and values.dtype != dtype: # pragma: no cover values = ...
[ "def", "_simple_blockify", "(", "tuples", ",", "dtype", ")", ":", "values", ",", "placement", "=", "_stack_arrays", "(", "tuples", ",", "dtype", ")", "# CHECK DTYPE?", "if", "dtype", "is", "not", "None", "and", "values", ".", "dtype", "!=", "dtype", ":", ...
return a single array of a block that has a single dtype; if dtype is not None, coerce to this dtype
[ "return", "a", "single", "array", "of", "a", "block", "that", "has", "a", "single", "dtype", ";", "if", "dtype", "is", "not", "None", "coerce", "to", "this", "dtype" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1792-L1803
19,593
pandas-dev/pandas
pandas/core/internals/managers.py
_multi_blockify
def _multi_blockify(tuples, dtype=None): """ return an array of blocks that potentially have different dtypes """ # group by dtype grouper = itertools.groupby(tuples, lambda x: x[2].dtype) new_blocks = [] for dtype, tup_block in grouper: values, placement = _stack_arrays(list(tup_block), ...
python
def _multi_blockify(tuples, dtype=None): """ return an array of blocks that potentially have different dtypes """ # group by dtype grouper = itertools.groupby(tuples, lambda x: x[2].dtype) new_blocks = [] for dtype, tup_block in grouper: values, placement = _stack_arrays(list(tup_block), ...
[ "def", "_multi_blockify", "(", "tuples", ",", "dtype", "=", "None", ")", ":", "# group by dtype", "grouper", "=", "itertools", ".", "groupby", "(", "tuples", ",", "lambda", "x", ":", "x", "[", "2", "]", ".", "dtype", ")", "new_blocks", "=", "[", "]", ...
return an array of blocks that potentially have different dtypes
[ "return", "an", "array", "of", "blocks", "that", "potentially", "have", "different", "dtypes" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1806-L1820
19,594
pandas-dev/pandas
pandas/core/internals/managers.py
_interleaved_dtype
def _interleaved_dtype( blocks: List[Block] ) -> Optional[Union[np.dtype, ExtensionDtype]]: """Find the common dtype for `blocks`. Parameters ---------- blocks : List[Block] Returns ------- dtype : Optional[Union[np.dtype, ExtensionDtype]] None is returned when `blocks` is ...
python
def _interleaved_dtype( blocks: List[Block] ) -> Optional[Union[np.dtype, ExtensionDtype]]: """Find the common dtype for `blocks`. Parameters ---------- blocks : List[Block] Returns ------- dtype : Optional[Union[np.dtype, ExtensionDtype]] None is returned when `blocks` is ...
[ "def", "_interleaved_dtype", "(", "blocks", ":", "List", "[", "Block", "]", ")", "->", "Optional", "[", "Union", "[", "np", ".", "dtype", ",", "ExtensionDtype", "]", "]", ":", "if", "not", "len", "(", "blocks", ")", ":", "return", "None", "return", "...
Find the common dtype for `blocks`. Parameters ---------- blocks : List[Block] Returns ------- dtype : Optional[Union[np.dtype, ExtensionDtype]] None is returned when `blocks` is empty.
[ "Find", "the", "common", "dtype", "for", "blocks", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1864-L1881
19,595
pandas-dev/pandas
pandas/core/internals/managers.py
_consolidate
def _consolidate(blocks): """ Merge blocks having same dtype, exclude non-consolidating blocks """ # sort by _can_consolidate, dtype gkey = lambda x: x._consolidate_key grouper = itertools.groupby(sorted(blocks, key=gkey), gkey) new_blocks = [] for (_can_consolidate, dtype), group_bloc...
python
def _consolidate(blocks): """ Merge blocks having same dtype, exclude non-consolidating blocks """ # sort by _can_consolidate, dtype gkey = lambda x: x._consolidate_key grouper = itertools.groupby(sorted(blocks, key=gkey), gkey) new_blocks = [] for (_can_consolidate, dtype), group_bloc...
[ "def", "_consolidate", "(", "blocks", ")", ":", "# sort by _can_consolidate, dtype", "gkey", "=", "lambda", "x", ":", "x", ".", "_consolidate_key", "grouper", "=", "itertools", ".", "groupby", "(", "sorted", "(", "blocks", ",", "key", "=", "gkey", ")", ",", ...
Merge blocks having same dtype, exclude non-consolidating blocks
[ "Merge", "blocks", "having", "same", "dtype", "exclude", "non", "-", "consolidating", "blocks" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1884-L1898
19,596
pandas-dev/pandas
pandas/core/internals/managers.py
_compare_or_regex_search
def _compare_or_regex_search(a, b, regex=False): """ Compare two array_like inputs of the same shape or two scalar values Calls operator.eq or re.search, depending on regex argument. If regex is True, perform an element-wise regex matching. Parameters ---------- a : array_like or scalar ...
python
def _compare_or_regex_search(a, b, regex=False): """ Compare two array_like inputs of the same shape or two scalar values Calls operator.eq or re.search, depending on regex argument. If regex is True, perform an element-wise regex matching. Parameters ---------- a : array_like or scalar ...
[ "def", "_compare_or_regex_search", "(", "a", ",", "b", ",", "regex", "=", "False", ")", ":", "if", "not", "regex", ":", "op", "=", "lambda", "x", ":", "operator", ".", "eq", "(", "x", ",", "b", ")", "else", ":", "op", "=", "np", ".", "vectorize",...
Compare two array_like inputs of the same shape or two scalar values Calls operator.eq or re.search, depending on regex argument. If regex is True, perform an element-wise regex matching. Parameters ---------- a : array_like or scalar b : array_like or scalar regex : bool, default False ...
[ "Compare", "two", "array_like", "inputs", "of", "the", "same", "shape", "or", "two", "scalar", "values" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1901-L1949
19,597
pandas-dev/pandas
pandas/core/internals/managers.py
items_overlap_with_suffix
def items_overlap_with_suffix(left, lsuffix, right, rsuffix): """ If two indices overlap, add suffixes to overlapping entries. If corresponding suffix is empty, the entry is simply converted to string. """ to_rename = left.intersection(right) if len(to_rename) == 0: return left, right ...
python
def items_overlap_with_suffix(left, lsuffix, right, rsuffix): """ If two indices overlap, add suffixes to overlapping entries. If corresponding suffix is empty, the entry is simply converted to string. """ to_rename = left.intersection(right) if len(to_rename) == 0: return left, right ...
[ "def", "items_overlap_with_suffix", "(", "left", ",", "lsuffix", ",", "right", ",", "rsuffix", ")", ":", "to_rename", "=", "left", ".", "intersection", "(", "right", ")", "if", "len", "(", "to_rename", ")", "==", "0", ":", "return", "left", ",", "right",...
If two indices overlap, add suffixes to overlapping entries. If corresponding suffix is empty, the entry is simply converted to string.
[ "If", "two", "indices", "overlap", "add", "suffixes", "to", "overlapping", "entries", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1956-L1994
19,598
pandas-dev/pandas
pandas/core/internals/managers.py
_transform_index
def _transform_index(index, func, level=None): """ Apply function to all values found in index. This includes transforming multiindex entries separately. Only apply function to one level of the MultiIndex if level is specified. """ if isinstance(index, MultiIndex): if level is not None...
python
def _transform_index(index, func, level=None): """ Apply function to all values found in index. This includes transforming multiindex entries separately. Only apply function to one level of the MultiIndex if level is specified. """ if isinstance(index, MultiIndex): if level is not None...
[ "def", "_transform_index", "(", "index", ",", "func", ",", "level", "=", "None", ")", ":", "if", "isinstance", "(", "index", ",", "MultiIndex", ")", ":", "if", "level", "is", "not", "None", ":", "items", "=", "[", "tuple", "(", "func", "(", "y", ")...
Apply function to all values found in index. This includes transforming multiindex entries separately. Only apply function to one level of the MultiIndex if level is specified.
[ "Apply", "function", "to", "all", "values", "found", "in", "index", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1997-L2014
19,599
pandas-dev/pandas
pandas/core/internals/managers.py
concatenate_block_managers
def concatenate_block_managers(mgrs_indexers, axes, concat_axis, copy): """ Concatenate block managers into one. Parameters ---------- mgrs_indexers : list of (BlockManager, {axis: indexer,...}) tuples axes : list of Index concat_axis : int copy : bool """ concat_plans = [get_m...
python
def concatenate_block_managers(mgrs_indexers, axes, concat_axis, copy): """ Concatenate block managers into one. Parameters ---------- mgrs_indexers : list of (BlockManager, {axis: indexer,...}) tuples axes : list of Index concat_axis : int copy : bool """ concat_plans = [get_m...
[ "def", "concatenate_block_managers", "(", "mgrs_indexers", ",", "axes", ",", "concat_axis", ",", "copy", ")", ":", "concat_plans", "=", "[", "get_mgr_concatenation_plan", "(", "mgr", ",", "indexers", ")", "for", "mgr", ",", "indexers", "in", "mgrs_indexers", "]"...
Concatenate block managers into one. Parameters ---------- mgrs_indexers : list of (BlockManager, {axis: indexer,...}) tuples axes : list of Index concat_axis : int copy : bool
[ "Concatenate", "block", "managers", "into", "one", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L2038-L2074