partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
Block._replace_coerce
Replace value corresponding to the given boolean array with another value. Parameters ---------- to_replace : object or pattern Scalar to replace or regular expression to match. value : object Replacement object. inplace : bool, default False ...
pandas/core/internals/blocks.py
def _replace_coerce(self, to_replace, value, inplace=True, regex=False, convert=False, mask=None): """ Replace value corresponding to the given boolean array with another value. Parameters ---------- to_replace : object or pattern Scal...
def _replace_coerce(self, to_replace, value, inplace=True, regex=False, convert=False, mask=None): """ Replace value corresponding to the given boolean array with another value. Parameters ---------- to_replace : object or pattern Scal...
[ "Replace", "value", "corresponding", "to", "the", "given", "boolean", "array", "with", "another", "value", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1474-L1509
[ "def", "_replace_coerce", "(", "self", ",", "to_replace", ",", "value", ",", "inplace", "=", "True", ",", "regex", "=", "False", ",", "convert", "=", "False", ",", "mask", "=", "None", ")", ":", "if", "mask", ".", "any", "(", ")", ":", "if", "not",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
NonConsolidatableMixIn.putmask
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 ...
pandas/core/internals/blocks.py
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): """ 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...
[ "putmask", "the", "data", "to", "the", "block", ";", "we", "must", "be", "a", "single", "block", "and", "not", "generate", "other", "blocks" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1564-L1597
[ "def", "putmask", "(", "self", ",", "mask", ",", "new", ",", "align", "=", "True", ",", "inplace", "=", "False", ",", "axis", "=", "0", ",", "transpose", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
NonConsolidatableMixIn._get_unstack_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 ---------...
pandas/core/internals/blocks.py
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): """ 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...
[ "Get", "the", "placement", "values", "and", "mask", "for", "a", "Block", "unstack", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1602-L1632
[ "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", ")",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
ExtensionBlock._maybe_coerce_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
pandas/core/internals/blocks.py
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): """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...
[ "Unbox", "to", "an", "extension", "array", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1651-L1667
[ "def", "_maybe_coerce_values", "(", "self", ",", "values", ")", ":", "if", "isinstance", "(", "values", ",", "(", "ABCIndexClass", ",", "ABCSeries", ")", ")", ":", "values", "=", "values", ".", "_values", "return", "values" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
ExtensionBlock.setitem
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...
pandas/core/internals/blocks.py
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): """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...
[ "Set", "the", "value", "inplace", "returning", "a", "same", "-", "typed", "block", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1693-L1721
[ "def", "setitem", "(", "self", ",", "indexer", ",", "value", ")", ":", "if", "isinstance", "(", "indexer", ",", "tuple", ")", ":", "# we are always 1-D", "indexer", "=", "indexer", "[", "0", "]", "check_setitem_lengths", "(", "indexer", ",", "value", ",", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
ExtensionBlock.take_nd
Take values according to indexer and return them as a block.
pandas/core/internals/blocks.py
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): """ 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...
[ "Take", "values", "according", "to", "indexer", "and", "return", "them", "as", "a", "block", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1733-L1754
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
ExtensionBlock._slice
return a slice of my values
pandas/core/internals/blocks.py
def _slice(self, slicer): """ return a slice of my values """ # slice the category # return same dims as we currently have if isinstance(slicer, tuple) and len(slicer) == 2: if not com.is_null_slice(slicer[0]): raise AssertionError("invalid slicing for a 1-n...
def _slice(self, slicer): """ return a slice of my values """ # slice the category # return same dims as we currently have if isinstance(slicer, tuple) and len(slicer) == 2: if not com.is_null_slice(slicer[0]): raise AssertionError("invalid slicing for a 1-n...
[ "return", "a", "slice", "of", "my", "values" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1761-L1773
[ "def", "_slice", "(", "self", ",", "slicer", ")", ":", "# slice the category", "# return same dims as we currently have", "if", "isinstance", "(", "slicer", ",", "tuple", ")", "and", "len", "(", "slicer", ")", "==", "2", ":", "if", "not", "com", ".", "is_nul...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
ExtensionBlock.concat_same_type
Concatenate list of single blocks of the same type.
pandas/core/internals/blocks.py
def concat_same_type(self, to_concat, placement=None): """ Concatenate list of single blocks of the same type. """ values = self._holder._concat_same_type( [blk.values for blk in to_concat]) placement = placement or slice(0, len(values), 1) return self.make_bl...
def concat_same_type(self, to_concat, placement=None): """ Concatenate list of single blocks of the same type. """ values = self._holder._concat_same_type( [blk.values for blk in to_concat]) placement = placement or slice(0, len(values), 1) return self.make_bl...
[ "Concatenate", "list", "of", "single", "blocks", "of", "the", "same", "type", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1790-L1798
[ "def", "concat_same_type", "(", "self", ",", "to_concat", ",", "placement", "=", "None", ")", ":", "values", "=", "self", ".", "_holder", ".", "_concat_same_type", "(", "[", "blk", ".", "values", "for", "blk", "in", "to_concat", "]", ")", "placement", "=...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
ExtensionBlock.shift
Shift the block by `periods`. Dispatches to underlying ExtensionArray and re-boxes in an ExtensionBlock.
pandas/core/internals/blocks.py
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']: """ Shift the block by `periods`. Dispatches to underlying ExtensionArray and re-boxes in an ExtensionBlock. """ ...
[ "Shift", "the", "block", "by", "periods", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1816-L1830
[ "def", "shift", "(", "self", ",", "periods", ":", "int", ",", "axis", ":", "libinternals", ".", "BlockPlacement", "=", "0", ",", "fill_value", ":", "Any", "=", "None", ")", "->", "List", "[", "'ExtensionBlock'", "]", ":", "return", "[", "self", ".", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
FloatBlock.to_native_types
convert to our native types format, slicing if desired
pandas/core/internals/blocks.py
def to_native_types(self, slicer=None, na_rep='', float_format=None, decimal='.', quoting=None, **kwargs): """ convert to our native types format, slicing if desired """ values = self.values if slicer is not None: values = values[:, slicer] # see gh-...
def to_native_types(self, slicer=None, na_rep='', float_format=None, decimal='.', quoting=None, **kwargs): """ convert to our native types format, slicing if desired """ values = self.values if slicer is not None: values = values[:, slicer] # see gh-...
[ "convert", "to", "our", "native", "types", "format", "slicing", "if", "desired" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1952-L1979
[ "def", "to_native_types", "(", "self", ",", "slicer", "=", "None", ",", "na_rep", "=", "''", ",", "float_format", "=", "None", ",", "decimal", "=", "'.'", ",", "quoting", "=", "None", ",", "*", "*", "kwargs", ")", ":", "values", "=", "self", ".", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeLikeBlockMixin.get_values
return object dtype as boxed values, such as Timestamps/Timedelta
pandas/core/internals/blocks.py
def get_values(self, dtype=None): """ return object dtype as boxed values, such as Timestamps/Timedelta """ if is_object_dtype(dtype): values = self.values.ravel() result = self._holder(values).astype(object) return result.reshape(self.values.shape) ...
def get_values(self, dtype=None): """ return object dtype as boxed values, such as Timestamps/Timedelta """ if is_object_dtype(dtype): values = self.values.ravel() result = self._holder(values).astype(object) return result.reshape(self.values.shape) ...
[ "return", "object", "dtype", "as", "boxed", "values", "such", "as", "Timestamps", "/", "Timedelta" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2040-L2048
[ "def", "get_values", "(", "self", ",", "dtype", "=", "None", ")", ":", "if", "is_object_dtype", "(", "dtype", ")", ":", "values", "=", "self", ".", "values", ".", "ravel", "(", ")", "result", "=", "self", ".", "_holder", "(", "values", ")", ".", "a...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeBlock._maybe_coerce_values
Input validation for values passed to __init__. Ensure that we have datetime64ns, coercing if necessary. Parameters ---------- values : array-like Must be convertible to datetime64 Returns ------- values : ndarray[datetime64ns] Overridden by...
pandas/core/internals/blocks.py
def _maybe_coerce_values(self, values): """Input validation for values passed to __init__. Ensure that we have datetime64ns, coercing if necessary. Parameters ---------- values : array-like Must be convertible to datetime64 Returns ------- va...
def _maybe_coerce_values(self, values): """Input validation for values passed to __init__. Ensure that we have datetime64ns, coercing if necessary. Parameters ---------- values : array-like Must be convertible to datetime64 Returns ------- va...
[ "Input", "validation", "for", "values", "passed", "to", "__init__", ".", "Ensure", "that", "we", "have", "datetime64ns", "coercing", "if", "necessary", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2060-L2082
[ "def", "_maybe_coerce_values", "(", "self", ",", "values", ")", ":", "if", "values", ".", "dtype", "!=", "_NS_DTYPE", ":", "values", "=", "conversion", ".", "ensure_datetime64ns", "(", "values", ")", "if", "isinstance", "(", "values", ",", "DatetimeArray", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeBlock._astype
these automatically copy, so copy=True has no effect raise on an except if raise == True
pandas/core/internals/blocks.py
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): """ 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...
[ "these", "automatically", "copy", "so", "copy", "=", "True", "has", "no", "effect", "raise", "on", "an", "except", "if", "raise", "==", "True" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2084-L2100
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeBlock._try_coerce_args
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...
pandas/core/internals/blocks.py
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): """ 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 ...
[ "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"...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2109-L2145
[ "def", "_try_coerce_args", "(", "self", ",", "values", ",", "other", ")", ":", "values", "=", "values", ".", "view", "(", "'i8'", ")", "if", "isinstance", "(", "other", ",", "bool", ")", ":", "raise", "TypeError", "elif", "is_null_datetimelike", "(", "ot...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeBlock._try_coerce_result
reverse of try_coerce_args
pandas/core/internals/blocks.py
def _try_coerce_result(self, result): """ reverse of try_coerce_args """ if isinstance(result, np.ndarray): if result.dtype.kind in ['i', 'f']: result = result.astype('M8[ns]') elif isinstance(result, (np.integer, np.float, np.datetime64)): result = self....
def _try_coerce_result(self, result): """ reverse of try_coerce_args """ if isinstance(result, np.ndarray): if result.dtype.kind in ['i', 'f']: result = result.astype('M8[ns]') elif isinstance(result, (np.integer, np.float, np.datetime64)): result = self....
[ "reverse", "of", "try_coerce_args" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2147-L2155
[ "def", "_try_coerce_result", "(", "self", ",", "result", ")", ":", "if", "isinstance", "(", "result", ",", "np", ".", "ndarray", ")", ":", "if", "result", ".", "dtype", ".", "kind", "in", "[", "'i'", ",", "'f'", "]", ":", "result", "=", "result", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeBlock.to_native_types
convert to our native types format, slicing if desired
pandas/core/internals/blocks.py
def to_native_types(self, slicer=None, na_rep=None, date_format=None, quoting=None, **kwargs): """ convert to our native types format, slicing if desired """ values = self.values i8values = self.values.view('i8') if slicer is not None: values = value...
def to_native_types(self, slicer=None, na_rep=None, date_format=None, quoting=None, **kwargs): """ convert to our native types format, slicing if desired """ values = self.values i8values = self.values.view('i8') if slicer is not None: values = value...
[ "convert", "to", "our", "native", "types", "format", "slicing", "if", "desired" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2161-L2178
[ "def", "to_native_types", "(", "self", ",", "slicer", "=", "None", ",", "na_rep", "=", "None", ",", "date_format", "=", "None", ",", "quoting", "=", "None", ",", "*", "*", "kwargs", ")", ":", "values", "=", "self", ".", "values", "i8values", "=", "se...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeBlock.set
Modify Block in-place with new item value Returns ------- None
pandas/core/internals/blocks.py
def set(self, locs, values): """ Modify Block in-place with new item value Returns ------- None """ values = conversion.ensure_datetime64ns(values, copy=False) self.values[locs] = values
def set(self, locs, values): """ Modify Block in-place with new item value Returns ------- None """ values = conversion.ensure_datetime64ns(values, copy=False) self.values[locs] = values
[ "Modify", "Block", "in", "-", "place", "with", "new", "item", "value" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2185-L2195
[ "def", "set", "(", "self", ",", "locs", ",", "values", ")", ":", "values", "=", "conversion", ".", "ensure_datetime64ns", "(", "values", ",", "copy", "=", "False", ")", "self", ".", "values", "[", "locs", "]", "=", "values" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeTZBlock._maybe_coerce_values
Input validation for values passed to __init__. Ensure that we have datetime64TZ, coercing if necessary. Parametetrs ----------- values : array-like Must be convertible to datetime64 Returns ------- values : DatetimeArray
pandas/core/internals/blocks.py
def _maybe_coerce_values(self, values): """Input validation for values passed to __init__. Ensure that we have datetime64TZ, coercing if necessary. Parametetrs ----------- values : array-like Must be convertible to datetime64 Returns ------- ...
def _maybe_coerce_values(self, values): """Input validation for values passed to __init__. Ensure that we have datetime64TZ, coercing if necessary. Parametetrs ----------- values : array-like Must be convertible to datetime64 Returns ------- ...
[ "Input", "validation", "for", "values", "passed", "to", "__init__", ".", "Ensure", "that", "we", "have", "datetime64TZ", "coercing", "if", "necessary", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2211-L2230
[ "def", "_maybe_coerce_values", "(", "self", ",", "values", ")", ":", "if", "not", "isinstance", "(", "values", ",", "self", ".", "_holder", ")", ":", "values", "=", "self", ".", "_holder", "(", "values", ")", "if", "values", ".", "tz", "is", "None", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeTZBlock.get_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...
pandas/core/internals/blocks.py
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): """ 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...
[ "Returns", "an", "ndarray", "of", "values", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2245-L2277
[ "def", "get_values", "(", "self", ",", "dtype", "=", "None", ")", ":", "values", "=", "self", ".", "values", "if", "is_object_dtype", "(", "dtype", ")", ":", "values", "=", "values", ".", "_box_values", "(", "values", ".", "_data", ")", "values", "=", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeTZBlock._slice
return a slice of my values
pandas/core/internals/blocks.py
def _slice(self, slicer): """ return a slice of my values """ if isinstance(slicer, tuple): col, loc = slicer if not com.is_null_slice(col) and col != 0: raise IndexError("{0} only contains one item".format(self)) return self.values[loc] return...
def _slice(self, slicer): """ return a slice of my values """ if isinstance(slicer, tuple): col, loc = slicer if not com.is_null_slice(col) and col != 0: raise IndexError("{0} only contains one item".format(self)) return self.values[loc] return...
[ "return", "a", "slice", "of", "my", "values" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2285-L2292
[ "def", "_slice", "(", "self", ",", "slicer", ")", ":", "if", "isinstance", "(", "slicer", ",", "tuple", ")", ":", "col", ",", "loc", "=", "slicer", "if", "not", "com", ".", "is_null_slice", "(", "col", ")", "and", "col", "!=", "0", ":", "raise", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeTZBlock._try_coerce_args
localize and return i8 for the values Parameters ---------- values : ndarray-like other : ndarray-like or scalar Returns ------- base-type values, base-type other
pandas/core/internals/blocks.py
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): """ 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...
[ "localize", "and", "return", "i8", "for", "the", "values" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2294-L2336
[ "def", "_try_coerce_args", "(", "self", ",", "values", ",", "other", ")", ":", "# asi8 is a view, needs copy", "values", "=", "_block_shape", "(", "values", ".", "view", "(", "\"i8\"", ")", ",", "ndim", "=", "self", ".", "ndim", ")", "if", "isinstance", "(...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeTZBlock._try_coerce_result
reverse of try_coerce_args
pandas/core/internals/blocks.py
def _try_coerce_result(self, result): """ reverse of try_coerce_args """ if isinstance(result, np.ndarray): if result.dtype.kind in ['i', 'f']: result = result.astype('M8[ns]') elif isinstance(result, (np.integer, np.float, np.datetime64)): result = self....
def _try_coerce_result(self, result): """ reverse of try_coerce_args """ if isinstance(result, np.ndarray): if result.dtype.kind in ['i', 'f']: result = result.astype('M8[ns]') elif isinstance(result, (np.integer, np.float, np.datetime64)): result = self....
[ "reverse", "of", "try_coerce_args" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2338-L2356
[ "def", "_try_coerce_result", "(", "self", ",", "result", ")", ":", "if", "isinstance", "(", "result", ",", "np", ".", "ndarray", ")", ":", "if", "result", ".", "dtype", ".", "kind", "in", "[", "'i'", ",", "'f'", "]", ":", "result", "=", "result", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeTZBlock.diff
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...
pandas/core/internals/blocks.py
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): """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 ...
[ "1st", "discrete", "difference" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2362-L2388
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
TimeDeltaBlock._try_coerce_args
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
pandas/core/internals/blocks.py
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): """ 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 ...
[ "Coerce", "values", "and", "other", "to", "int64", "with", "null", "values", "converted", "to", "iNaT", ".", "values", "is", "always", "ndarray", "-", "like", "other", "may", "not", "be" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2477-L2506
[ "def", "_try_coerce_args", "(", "self", ",", "values", ",", "other", ")", ":", "values", "=", "values", ".", "view", "(", "'i8'", ")", "if", "isinstance", "(", "other", ",", "bool", ")", ":", "raise", "TypeError", "elif", "is_null_datetimelike", "(", "ot...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
TimeDeltaBlock._try_coerce_result
reverse of try_coerce_args / try_operate
pandas/core/internals/blocks.py
def _try_coerce_result(self, result): """ reverse of try_coerce_args / try_operate """ if isinstance(result, np.ndarray): mask = isna(result) if result.dtype.kind in ['i', 'f']: result = result.astype('m8[ns]') result[mask] = tslibs.iNaT elif ...
def _try_coerce_result(self, result): """ reverse of try_coerce_args / try_operate """ if isinstance(result, np.ndarray): mask = isna(result) if result.dtype.kind in ['i', 'f']: result = result.astype('m8[ns]') result[mask] = tslibs.iNaT elif ...
[ "reverse", "of", "try_coerce_args", "/", "try_operate" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2508-L2519
[ "def", "_try_coerce_result", "(", "self", ",", "result", ")", ":", "if", "isinstance", "(", "result", ",", "np", ".", "ndarray", ")", ":", "mask", "=", "isna", "(", "result", ")", "if", "result", ".", "dtype", ".", "kind", "in", "[", "'i'", ",", "'...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
TimeDeltaBlock.to_native_types
convert to our native types format, slicing if desired
pandas/core/internals/blocks.py
def to_native_types(self, slicer=None, na_rep=None, quoting=None, **kwargs): """ convert to our native types format, slicing if desired """ values = self.values if slicer is not None: values = values[:, slicer] mask = isna(values) rvalues = n...
def to_native_types(self, slicer=None, na_rep=None, quoting=None, **kwargs): """ convert to our native types format, slicing if desired """ values = self.values if slicer is not None: values = values[:, slicer] mask = isna(values) rvalues = n...
[ "convert", "to", "our", "native", "types", "format", "slicing", "if", "desired" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2525-L2547
[ "def", "to_native_types", "(", "self", ",", "slicer", "=", "None", ",", "na_rep", "=", "None", ",", "quoting", "=", "None", ",", "*", "*", "kwargs", ")", ":", "values", "=", "self", ".", "values", "if", "slicer", "is", "not", "None", ":", "values", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
ObjectBlock.convert
attempt to coerce any object types to better types return a copy of the block (if copy = True) by definition we ARE an ObjectBlock!!!!! can return multiple blocks!
pandas/core/internals/blocks.py
def convert(self, *args, **kwargs): """ attempt to coerce any object types to better types return a copy of the block (if copy = True) by definition we ARE an ObjectBlock!!!!! can return multiple blocks! """ if args: raise NotImplementedError by_item = kwarg...
def convert(self, *args, **kwargs): """ attempt to coerce any object types to better types return a copy of the block (if copy = True) by definition we ARE an ObjectBlock!!!!! can return multiple blocks! """ if args: raise NotImplementedError by_item = kwarg...
[ "attempt", "to", "coerce", "any", "object", "types", "to", "better", "types", "return", "a", "copy", "of", "the", "block", "(", "if", "copy", "=", "True", ")", "by", "definition", "we", "ARE", "an", "ObjectBlock!!!!!" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2597-L2643
[ "def", "convert", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "args", ":", "raise", "NotImplementedError", "by_item", "=", "kwargs", ".", "get", "(", "'by_item'", ",", "True", ")", "new_inputs", "=", "[", "'coerce'", ",", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
ObjectBlock.set
Modify Block in-place with new item value Returns ------- None
pandas/core/internals/blocks.py
def set(self, locs, values): """ Modify Block in-place with new item value Returns ------- None """ try: self.values[locs] = values except (ValueError): # broadcasting error # see GH6171 new_shape = list(va...
def set(self, locs, values): """ Modify Block in-place with new item value Returns ------- None """ try: self.values[locs] = values except (ValueError): # broadcasting error # see GH6171 new_shape = list(va...
[ "Modify", "Block", "in", "-", "place", "with", "new", "item", "value" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2645-L2663
[ "def", "set", "(", "self", ",", "locs", ",", "values", ")", ":", "try", ":", "self", ".", "values", "[", "locs", "]", "=", "values", "except", "(", "ValueError", ")", ":", "# broadcasting error", "# see GH6171", "new_shape", "=", "list", "(", "values", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
ObjectBlock._try_coerce_args
provide coercion to our input arguments
pandas/core/internals/blocks.py
def _try_coerce_args(self, values, other): """ provide coercion to our input arguments """ if isinstance(other, ABCDatetimeIndex): # May get a DatetimeIndex here. Unbox it. other = other.array if isinstance(other, DatetimeArray): # hit in pandas/tests/indexi...
def _try_coerce_args(self, values, other): """ provide coercion to our input arguments """ if isinstance(other, ABCDatetimeIndex): # May get a DatetimeIndex here. Unbox it. other = other.array if isinstance(other, DatetimeArray): # hit in pandas/tests/indexi...
[ "provide", "coercion", "to", "our", "input", "arguments" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2677-L2690
[ "def", "_try_coerce_args", "(", "self", ",", "values", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "ABCDatetimeIndex", ")", ":", "# May get a DatetimeIndex here. Unbox it.", "other", "=", "other", ".", "array", "if", "isinstance", "(", "other"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
ObjectBlock._replace_single
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. ...
pandas/core/internals/blocks.py
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): """ Replace elements by the given value. Parameters ---------- to_replace : object or pattern Scalar to replace or regular expressi...
[ "Replace", "elements", "by", "the", "given", "value", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2744-L2841
[ "def", "_replace_single", "(", "self", ",", "to_replace", ",", "value", ",", "inplace", "=", "False", ",", "filter", "=", "None", ",", "regex", "=", "False", ",", "convert", "=", "True", ",", "mask", "=", "None", ")", ":", "inplace", "=", "validate_boo...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
ObjectBlock._replace_coerce
Replace value corresponding to the given boolean array with another value. Parameters ---------- to_replace : object or pattern Scalar to replace or regular expression to match. value : object Replacement object. inplace : bool, default False ...
pandas/core/internals/blocks.py
def _replace_coerce(self, to_replace, value, inplace=True, regex=False, convert=False, mask=None): """ Replace value corresponding to the given boolean array with another value. Parameters ---------- to_replace : object or pattern Scal...
def _replace_coerce(self, to_replace, value, inplace=True, regex=False, convert=False, mask=None): """ Replace value corresponding to the given boolean array with another value. Parameters ---------- to_replace : object or pattern Scal...
[ "Replace", "value", "corresponding", "to", "the", "given", "boolean", "array", "with", "another", "value", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2843-L2876
[ "def", "_replace_coerce", "(", "self", ",", "to_replace", ",", "value", ",", "inplace", "=", "True", ",", "regex", "=", "False", ",", "convert", "=", "False", ",", "mask", "=", "None", ")", ":", "if", "mask", ".", "any", "(", ")", ":", "block", "="...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
CategoricalBlock._try_coerce_result
reverse of try_coerce_args
pandas/core/internals/blocks.py
def _try_coerce_result(self, result): """ reverse of try_coerce_args """ # GH12564: CategoricalBlock is 1-dim only # while returned results could be any dim if ((not is_categorical_dtype(result)) and isinstance(result, np.ndarray)): result = _block_shape(resu...
def _try_coerce_result(self, result): """ reverse of try_coerce_args """ # GH12564: CategoricalBlock is 1-dim only # while returned results could be any dim if ((not is_categorical_dtype(result)) and isinstance(result, np.ndarray)): result = _block_shape(resu...
[ "reverse", "of", "try_coerce_args" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2905-L2914
[ "def", "_try_coerce_result", "(", "self", ",", "result", ")", ":", "# GH12564: CategoricalBlock is 1-dim only", "# while returned results could be any dim", "if", "(", "(", "not", "is_categorical_dtype", "(", "result", ")", ")", "and", "isinstance", "(", "result", ",", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
CategoricalBlock.to_native_types
convert to our native types format, slicing if desired
pandas/core/internals/blocks.py
def to_native_types(self, slicer=None, na_rep='', quoting=None, **kwargs): """ convert to our native types format, slicing if desired """ values = self.values if slicer is not None: # Categorical is always one dimension values = values[slicer] mask = isna(values)...
def to_native_types(self, slicer=None, na_rep='', quoting=None, **kwargs): """ convert to our native types format, slicing if desired """ values = self.values if slicer is not None: # Categorical is always one dimension values = values[slicer] mask = isna(values)...
[ "convert", "to", "our", "native", "types", "format", "slicing", "if", "desired" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2922-L2934
[ "def", "to_native_types", "(", "self", ",", "slicer", "=", "None", ",", "na_rep", "=", "''", ",", "quoting", "=", "None", ",", "*", "*", "kwargs", ")", ":", "values", "=", "self", ".", "values", "if", "slicer", "is", "not", "None", ":", "# Categorica...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_XlwtWriter._style_to_xlwt
helper which recursively generate an xlwt easy style string for example: hstyle = {"font": {"bold": True}, "border": {"top": "thin", "right": "thin", "bottom": "thin", "left": "thin"}, "align": {"horiz": "center"}} ...
pandas/io/excel/_xlwt.py
def _style_to_xlwt(cls, item, firstlevel=True, field_sep=',', line_sep=';'): """helper which recursively generate an xlwt easy style string for example: hstyle = {"font": {"bold": True}, "border": {"top": "thin", "right": "thin", ...
def _style_to_xlwt(cls, item, firstlevel=True, field_sep=',', line_sep=';'): """helper which recursively generate an xlwt easy style string for example: hstyle = {"font": {"bold": True}, "border": {"top": "thin", "right": "thin", ...
[ "helper", "which", "recursively", "generate", "an", "xlwt", "easy", "style", "string", "for", "example", ":" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_xlwt.py#L78-L111
[ "def", "_style_to_xlwt", "(", "cls", ",", "item", ",", "firstlevel", "=", "True", ",", "field_sep", "=", "','", ",", "line_sep", "=", "';'", ")", ":", "if", "hasattr", "(", "item", ",", "'items'", ")", ":", "if", "firstlevel", ":", "it", "=", "[", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_XlwtWriter._convert_to_style
converts a style_dict to an xlwt style object Parameters ---------- style_dict : style dictionary to convert num_format_str : optional number format string
pandas/io/excel/_xlwt.py
def _convert_to_style(cls, style_dict, num_format_str=None): """ converts a style_dict to an xlwt style object Parameters ---------- style_dict : style dictionary to convert num_format_str : optional number format string """ import xlwt if style_d...
def _convert_to_style(cls, style_dict, num_format_str=None): """ converts a style_dict to an xlwt style object Parameters ---------- style_dict : style dictionary to convert num_format_str : optional number format string """ import xlwt if style_d...
[ "converts", "a", "style_dict", "to", "an", "xlwt", "style", "object", "Parameters", "----------", "style_dict", ":", "style", "dictionary", "to", "convert", "num_format_str", ":", "optional", "number", "format", "string" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_xlwt.py#L114-L132
[ "def", "_convert_to_style", "(", "cls", ",", "style_dict", ",", "num_format_str", "=", "None", ")", ":", "import", "xlwt", "if", "style_dict", ":", "xlwt_stylestr", "=", "cls", ".", "_style_to_xlwt", "(", "style_dict", ")", "style", "=", "xlwt", ".", "easyxf...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_XlsxStyler.convert
converts a style_dict to an xlsxwriter format dict Parameters ---------- style_dict : style dictionary to convert num_format_str : optional number format string
pandas/io/excel/_xlsxwriter.py
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): """ 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...
[ "converts", "a", "style_dict", "to", "an", "xlsxwriter", "format", "dict" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_xlsxwriter.py#L85-L147
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_unstack_extension_series
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 ...
pandas/core/reshape/reshape.py
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): """ 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...
[ "Unstack", "an", "ExtensionArray", "-", "backed", "Series", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/reshape.py#L411-L454
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
stack
Convert DataFrame to Series with multi-level Index. Columns become the second level of the resulting hierarchical index Returns ------- stacked : Series
pandas/core/reshape/reshape.py
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): """ 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...
[ "Convert", "DataFrame", "to", "Series", "with", "multi", "-", "level", "Index", ".", "Columns", "become", "the", "second", "level", "of", "the", "resulting", "hierarchical", "index" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/reshape.py#L457-L524
[ "def", "stack", "(", "frame", ",", "level", "=", "-", "1", ",", "dropna", "=", "True", ")", ":", "def", "factorize", "(", "index", ")", ":", "if", "index", ".", "is_unique", ":", "return", "index", ",", "np", ".", "arange", "(", "len", "(", "inde...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
get_dummies
Convert categorical variable into dummy/indicator variables. Parameters ---------- data : array-like, Series, or DataFrame Data of which to get dummy indicators. prefix : str, list of str, or dict of str, default None String to append DataFrame column names. Pass a list with len...
pandas/core/reshape/reshape.py
def get_dummies(data, prefix=None, prefix_sep='_', dummy_na=False, columns=None, sparse=False, drop_first=False, dtype=None): """ Convert categorical variable into dummy/indicator variables. Parameters ---------- data : array-like, Series, or DataFrame Data of which to get d...
def get_dummies(data, prefix=None, prefix_sep='_', dummy_na=False, columns=None, sparse=False, drop_first=False, dtype=None): """ Convert categorical variable into dummy/indicator variables. Parameters ---------- data : array-like, Series, or DataFrame Data of which to get d...
[ "Convert", "categorical", "variable", "into", "dummy", "/", "indicator", "variables", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/reshape.py#L697-L865
[ "def", "get_dummies", "(", "data", ",", "prefix", "=", "None", ",", "prefix_sep", "=", "'_'", ",", "dummy_na", "=", "False", ",", "columns", "=", "None", ",", "sparse", "=", "False", ",", "drop_first", "=", "False", ",", "dtype", "=", "None", ")", ":...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
make_axis_dummies
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...
pandas/core/reshape/reshape.py
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): """ 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...
[ "Construct", "1", "-", "0", "dummy", "variables", "corresponding", "to", "designated", "axis", "labels" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/reshape.py#L970-L1003
[ "def", "make_axis_dummies", "(", "frame", ",", "axis", "=", "'minor'", ",", "transform", "=", "None", ")", ":", "numbers", "=", "{", "'major'", ":", "0", ",", "'minor'", ":", "1", "}", "num", "=", "numbers", ".", "get", "(", "axis", ",", "axis", ")...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_reorder_for_extension_array_stack
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...
pandas/core/reshape/reshape.py
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): """ 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 : ...
[ "Re", "-", "orders", "the", "values", "when", "stacking", "multiple", "extension", "-", "arrays", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/reshape.py#L1006-L1038
[ "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", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_split_line
Parameters ---------- s: string Fixed-length string to split parts: list of (name, length) pairs Used to break up string, name '_' will be filtered from output. Returns ------- Dict of name:contents of string at given location.
pandas/io/sas/sas_xport.py
def _split_line(s, parts): """ Parameters ---------- s: string Fixed-length string to split parts: list of (name, length) pairs Used to break up string, name '_' will be filtered from output. Returns ------- Dict of name:contents of string at given location. """ ...
def _split_line(s, parts): """ Parameters ---------- s: string Fixed-length string to split parts: list of (name, length) pairs Used to break up string, name '_' will be filtered from output. Returns ------- Dict of name:contents of string at given location. """ ...
[ "Parameters", "----------", "s", ":", "string", "Fixed", "-", "length", "string", "to", "split", "parts", ":", "list", "of", "(", "name", "length", ")", "pairs", "Used", "to", "break", "up", "string", "name", "_", "will", "be", "filtered", "from", "outpu...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sas/sas_xport.py#L129-L148
[ "def", "_split_line", "(", "s", ",", "parts", ")", ":", "out", "=", "{", "}", "start", "=", "0", "for", "name", ",", "length", "in", "parts", ":", "out", "[", "name", "]", "=", "s", "[", "start", ":", "start", "+", "length", "]", ".", "strip", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_parse_float_vec
Parse a vector of float values representing IBM 8 byte floats into native 8 byte floats.
pandas/io/sas/sas_xport.py
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): """ 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...
[ "Parse", "a", "vector", "of", "float", "values", "representing", "IBM", "8", "byte", "floats", "into", "native", "8", "byte", "floats", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sas/sas_xport.py#L170-L224
[ "def", "_parse_float_vec", "(", "vec", ")", ":", "dtype", "=", "np", ".", "dtype", "(", "'>u4,>u4'", ")", "vec1", "=", "vec", ".", "view", "(", "dtype", "=", "dtype", ")", "xport1", "=", "vec1", "[", "'f0'", "]", "xport2", "=", "vec1", "[", "'f1'",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
XportReader._record_count
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.
pandas/io/sas/sas_xport.py
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): """ 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....
[ "Get", "number", "of", "records", "in", "file", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sas/sas_xport.py#L364-L399
[ "def", "_record_count", "(", "self", ")", ":", "self", ".", "filepath_or_buffer", ".", "seek", "(", "0", ",", "2", ")", "total_records_length", "=", "(", "self", ".", "filepath_or_buffer", ".", "tell", "(", ")", "-", "self", ".", "record_start", ")", "if...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
XportReader.get_chunk
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
pandas/io/sas/sas_xport.py
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): """ 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 ...
[ "Reads", "lines", "from", "Xport", "file", "and", "returns", "as", "dataframe" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sas/sas_xport.py#L401-L416
[ "def", "get_chunk", "(", "self", ",", "size", "=", "None", ")", ":", "if", "size", "is", "None", ":", "size", "=", "self", ".", "_chunksize", "return", "self", ".", "read", "(", "nrows", "=", "size", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
construction_error
raise a helpful message about our construction
pandas/core/internals/managers.py
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): """ 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] ...
[ "raise", "a", "helpful", "message", "about", "our", "construction" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1670-L1687
[ "def", "construction_error", "(", "tot_items", ",", "block_shape", ",", "axes", ",", "e", "=", "None", ")", ":", "passed", "=", "tuple", "(", "map", "(", "int", ",", "[", "tot_items", "]", "+", "list", "(", "block_shape", ")", ")", ")", "# Correcting t...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_simple_blockify
return a single array of a block that has a single dtype; if dtype is not None, coerce to this dtype
pandas/core/internals/managers.py
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): """ 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 = ...
[ "return", "a", "single", "array", "of", "a", "block", "that", "has", "a", "single", "dtype", ";", "if", "dtype", "is", "not", "None", "coerce", "to", "this", "dtype" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1792-L1803
[ "def", "_simple_blockify", "(", "tuples", ",", "dtype", ")", ":", "values", ",", "placement", "=", "_stack_arrays", "(", "tuples", ",", "dtype", ")", "# CHECK DTYPE?", "if", "dtype", "is", "not", "None", "and", "values", ".", "dtype", "!=", "dtype", ":", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_multi_blockify
return an array of blocks that potentially have different dtypes
pandas/core/internals/managers.py
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): """ 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), ...
[ "return", "an", "array", "of", "blocks", "that", "potentially", "have", "different", "dtypes" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1806-L1820
[ "def", "_multi_blockify", "(", "tuples", ",", "dtype", "=", "None", ")", ":", "# group by dtype", "grouper", "=", "itertools", ".", "groupby", "(", "tuples", ",", "lambda", "x", ":", "x", "[", "2", "]", ".", "dtype", ")", "new_blocks", "=", "[", "]", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_sparse_blockify
return an array of blocks that potentially have different dtypes (and are sparse)
pandas/core/internals/managers.py
def _sparse_blockify(tuples, dtype=None): """ return an array of blocks that potentially have different dtypes (and are sparse) """ new_blocks = [] for i, names, array in tuples: array = _maybe_to_sparse(array) block = make_block(array, placement=[i]) new_blocks.append(block...
def _sparse_blockify(tuples, dtype=None): """ return an array of blocks that potentially have different dtypes (and are sparse) """ new_blocks = [] for i, names, array in tuples: array = _maybe_to_sparse(array) block = make_block(array, placement=[i]) new_blocks.append(block...
[ "return", "an", "array", "of", "blocks", "that", "potentially", "have", "different", "dtypes", "(", "and", "are", "sparse", ")" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1823-L1834
[ "def", "_sparse_blockify", "(", "tuples", ",", "dtype", "=", "None", ")", ":", "new_blocks", "=", "[", "]", "for", "i", ",", "names", ",", "array", "in", "tuples", ":", "array", "=", "_maybe_to_sparse", "(", "array", ")", "block", "=", "make_block", "(...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_interleaved_dtype
Find the common dtype for `blocks`. Parameters ---------- blocks : List[Block] Returns ------- dtype : Optional[Union[np.dtype, ExtensionDtype]] None is returned when `blocks` is empty.
pandas/core/internals/managers.py
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]]: """Find the common dtype for `blocks`. Parameters ---------- blocks : List[Block] Returns ------- dtype : Optional[Union[np.dtype, ExtensionDtype]] None is returned when `blocks` is ...
[ "Find", "the", "common", "dtype", "for", "blocks", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1864-L1881
[ "def", "_interleaved_dtype", "(", "blocks", ":", "List", "[", "Block", "]", ")", "->", "Optional", "[", "Union", "[", "np", ".", "dtype", ",", "ExtensionDtype", "]", "]", ":", "if", "not", "len", "(", "blocks", ")", ":", "return", "None", "return", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_consolidate
Merge blocks having same dtype, exclude non-consolidating blocks
pandas/core/internals/managers.py
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): """ 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...
[ "Merge", "blocks", "having", "same", "dtype", "exclude", "non", "-", "consolidating", "blocks" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1884-L1898
[ "def", "_consolidate", "(", "blocks", ")", ":", "# sort by _can_consolidate, dtype", "gkey", "=", "lambda", "x", ":", "x", ".", "_consolidate_key", "grouper", "=", "itertools", ".", "groupby", "(", "sorted", "(", "blocks", ",", "key", "=", "gkey", ")", ",", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_compare_or_regex_search
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 ...
pandas/core/internals/managers.py
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): """ 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 ...
[ "Compare", "two", "array_like", "inputs", "of", "the", "same", "shape", "or", "two", "scalar", "values" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1901-L1949
[ "def", "_compare_or_regex_search", "(", "a", ",", "b", ",", "regex", "=", "False", ")", ":", "if", "not", "regex", ":", "op", "=", "lambda", "x", ":", "operator", ".", "eq", "(", "x", ",", "b", ")", "else", ":", "op", "=", "np", ".", "vectorize",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
items_overlap_with_suffix
If two indices overlap, add suffixes to overlapping entries. If corresponding suffix is empty, the entry is simply converted to string.
pandas/core/internals/managers.py
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): """ 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 ...
[ "If", "two", "indices", "overlap", "add", "suffixes", "to", "overlapping", "entries", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1956-L1994
[ "def", "items_overlap_with_suffix", "(", "left", ",", "lsuffix", ",", "right", ",", "rsuffix", ")", ":", "to_rename", "=", "left", ".", "intersection", "(", "right", ")", "if", "len", "(", "to_rename", ")", "==", "0", ":", "return", "left", ",", "right",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_transform_index
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.
pandas/core/internals/managers.py
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): """ 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...
[ "Apply", "function", "to", "all", "values", "found", "in", "index", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1997-L2014
[ "def", "_transform_index", "(", "index", ",", "func", ",", "level", "=", "None", ")", ":", "if", "isinstance", "(", "index", ",", "MultiIndex", ")", ":", "if", "level", "is", "not", "None", ":", "items", "=", "[", "tuple", "(", "func", "(", "y", ")...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_fast_count_smallints
Faster version of set(arr) for sequences of small numbers.
pandas/core/internals/managers.py
def _fast_count_smallints(arr): """Faster version of set(arr) for sequences of small numbers.""" counts = np.bincount(arr.astype(np.int_)) nz = counts.nonzero()[0] return np.c_[nz, counts[nz]]
def _fast_count_smallints(arr): """Faster version of set(arr) for sequences of small numbers.""" counts = np.bincount(arr.astype(np.int_)) nz = counts.nonzero()[0] return np.c_[nz, counts[nz]]
[ "Faster", "version", "of", "set", "(", "arr", ")", "for", "sequences", "of", "small", "numbers", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L2017-L2021
[ "def", "_fast_count_smallints", "(", "arr", ")", ":", "counts", "=", "np", ".", "bincount", "(", "arr", ".", "astype", "(", "np", ".", "int_", ")", ")", "nz", "=", "counts", ".", "nonzero", "(", ")", "[", "0", "]", "return", "np", ".", "c_", "[",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
concatenate_block_managers
Concatenate block managers into one. Parameters ---------- mgrs_indexers : list of (BlockManager, {axis: indexer,...}) tuples axes : list of Index concat_axis : int copy : bool
pandas/core/internals/managers.py
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): """ 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...
[ "Concatenate", "block", "managers", "into", "one", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L2038-L2074
[ "def", "concatenate_block_managers", "(", "mgrs_indexers", ",", "axes", ",", "concat_axis", ",", "copy", ")", ":", "concat_plans", "=", "[", "get_mgr_concatenation_plan", "(", "mgr", ",", "indexers", ")", "for", "mgr", ",", "indexers", "in", "mgrs_indexers", "]"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.make_empty
return an empty BlockManager with the items axis of len 0
pandas/core/internals/managers.py
def make_empty(self, axes=None): """ return an empty BlockManager with the items axis of len 0 """ if axes is None: axes = [ensure_index([])] + [ensure_index(a) for a in self.axes[1:]] # preserve dtype if possible if self.ndim == 1: ...
def make_empty(self, axes=None): """ return an empty BlockManager with the items axis of len 0 """ if axes is None: axes = [ensure_index([])] + [ensure_index(a) for a in self.axes[1:]] # preserve dtype if possible if self.ndim == 1: ...
[ "return", "an", "empty", "BlockManager", "with", "the", "items", "axis", "of", "len", "0" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L120-L131
[ "def", "make_empty", "(", "self", ",", "axes", "=", "None", ")", ":", "if", "axes", "is", "None", ":", "axes", "=", "[", "ensure_index", "(", "[", "]", ")", "]", "+", "[", "ensure_index", "(", "a", ")", "for", "a", "in", "self", ".", "axes", "[...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.rename_axis
Rename one of axes. Parameters ---------- mapper : unary callable axis : int copy : boolean, default True level : int, default None
pandas/core/internals/managers.py
def rename_axis(self, mapper, axis, copy=True, level=None): """ Rename one of axes. Parameters ---------- mapper : unary callable axis : int copy : boolean, default True level : int, default None """ obj = self.copy(deep=copy) obj....
def rename_axis(self, mapper, axis, copy=True, level=None): """ Rename one of axes. Parameters ---------- mapper : unary callable axis : int copy : boolean, default True level : int, default None """ obj = self.copy(deep=copy) obj....
[ "Rename", "one", "of", "axes", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L159-L172
[ "def", "rename_axis", "(", "self", ",", "mapper", ",", "axis", ",", "copy", "=", "True", ",", "level", "=", "None", ")", ":", "obj", "=", "self", ".", "copy", "(", "deep", "=", "copy", ")", "obj", ".", "set_axis", "(", "axis", ",", "_transform_inde...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager._rebuild_blknos_and_blklocs
Update mgr._blknos / mgr._blklocs.
pandas/core/internals/managers.py
def _rebuild_blknos_and_blklocs(self): """ Update mgr._blknos / mgr._blklocs. """ new_blknos = np.empty(self.shape[0], dtype=np.int64) new_blklocs = np.empty(self.shape[0], dtype=np.int64) new_blknos.fill(-1) new_blklocs.fill(-1) for blkno, blk in enumera...
def _rebuild_blknos_and_blklocs(self): """ Update mgr._blknos / mgr._blklocs. """ new_blknos = np.empty(self.shape[0], dtype=np.int64) new_blklocs = np.empty(self.shape[0], dtype=np.int64) new_blknos.fill(-1) new_blklocs.fill(-1) for blkno, blk in enumera...
[ "Update", "mgr", ".", "_blknos", "/", "mgr", ".", "_blklocs", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L186-L204
[ "def", "_rebuild_blknos_and_blklocs", "(", "self", ")", ":", "new_blknos", "=", "np", ".", "empty", "(", "self", ".", "shape", "[", "0", "]", ",", "dtype", "=", "np", ".", "int64", ")", "new_blklocs", "=", "np", ".", "empty", "(", "self", ".", "shape...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager._get_counts
return a dict of the counts of the function in BlockManager
pandas/core/internals/managers.py
def _get_counts(self, f): """ return a dict of the counts of the function in BlockManager """ self._consolidate_inplace() counts = dict() for b in self.blocks: v = f(b) counts[v] = counts.get(v, 0) + b.shape[0] return counts
def _get_counts(self, f): """ return a dict of the counts of the function in BlockManager """ self._consolidate_inplace() counts = dict() for b in self.blocks: v = f(b) counts[v] = counts.get(v, 0) + b.shape[0] return counts
[ "return", "a", "dict", "of", "the", "counts", "of", "the", "function", "in", "BlockManager" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L210-L217
[ "def", "_get_counts", "(", "self", ",", "f", ")", ":", "self", ".", "_consolidate_inplace", "(", ")", "counts", "=", "dict", "(", ")", "for", "b", "in", "self", ".", "blocks", ":", "v", "=", "f", "(", "b", ")", "counts", "[", "v", "]", "=", "co...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.apply
iterate over the blocks, collect and create a new block manager Parameters ---------- f : the callable or function name to operate on at the block level axes : optional (if not supplied, use self.axes) filter : list, if supplied, only call the block if the filter is in ...
pandas/core/internals/managers.py
def apply(self, f, axes=None, filter=None, do_integrity_check=False, consolidate=True, **kwargs): """ iterate over the blocks, collect and create a new block manager Parameters ---------- f : the callable or function name to operate on at the block level ax...
def apply(self, f, axes=None, filter=None, do_integrity_check=False, consolidate=True, **kwargs): """ iterate over the blocks, collect and create a new block manager Parameters ---------- f : the callable or function name to operate on at the block level ax...
[ "iterate", "over", "the", "blocks", "collect", "and", "create", "a", "new", "block", "manager" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L318-L403
[ "def", "apply", "(", "self", ",", "f", ",", "axes", "=", "None", ",", "filter", "=", "None", ",", "do_integrity_check", "=", "False", ",", "consolidate", "=", "True", ",", "*", "*", "kwargs", ")", ":", "result_blocks", "=", "[", "]", "# filter kwarg is...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.quantile
Iterate over blocks applying quantile reduction. This routine is intended for reduction type operations and will do inference on the generated blocks. Parameters ---------- axis: reduction axis, default 0 consolidate: boolean, default True. Join together blocks having sa...
pandas/core/internals/managers.py
def quantile(self, axis=0, consolidate=True, transposed=False, interpolation='linear', qs=None, numeric_only=None): """ Iterate over blocks applying quantile reduction. This routine is intended for reduction type operations and will do inference on the generated blocks. ...
def quantile(self, axis=0, consolidate=True, transposed=False, interpolation='linear', qs=None, numeric_only=None): """ Iterate over blocks applying quantile reduction. This routine is intended for reduction type operations and will do inference on the generated blocks. ...
[ "Iterate", "over", "blocks", "applying", "quantile", "reduction", ".", "This", "routine", "is", "intended", "for", "reduction", "type", "operations", "and", "will", "do", "inference", "on", "the", "generated", "blocks", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L405-L501
[ "def", "quantile", "(", "self", ",", "axis", "=", "0", ",", "consolidate", "=", "True", ",", "transposed", "=", "False", ",", "interpolation", "=", "'linear'", ",", "qs", "=", "None", ",", "numeric_only", "=", "None", ")", ":", "# Series dispatches to Data...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.replace_list
do a list replace
pandas/core/internals/managers.py
def replace_list(self, src_list, dest_list, inplace=False, regex=False): """ do a list replace """ inplace = validate_bool_kwarg(inplace, 'inplace') # figure out our mask a-priori to avoid repeated replacements values = self.as_array() def comp(s, regex=False): """...
def replace_list(self, src_list, dest_list, inplace=False, regex=False): """ do a list replace """ inplace = validate_bool_kwarg(inplace, 'inplace') # figure out our mask a-priori to avoid repeated replacements values = self.as_array() def comp(s, regex=False): """...
[ "do", "a", "list", "replace" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L539-L585
[ "def", "replace_list", "(", "self", ",", "src_list", ",", "dest_list", ",", "inplace", "=", "False", ",", "regex", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "# figure out our mask a-priori to avoid repeat...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.get_bool_data
Parameters ---------- copy : boolean, default False Whether to copy the blocks
pandas/core/internals/managers.py
def get_bool_data(self, copy=False): """ Parameters ---------- copy : boolean, default False Whether to copy the blocks """ self._consolidate_inplace() return self.combine([b for b in self.blocks if b.is_bool], copy)
def get_bool_data(self, copy=False): """ Parameters ---------- copy : boolean, default False Whether to copy the blocks """ self._consolidate_inplace() return self.combine([b for b in self.blocks if b.is_bool], copy)
[ "Parameters", "----------", "copy", ":", "boolean", "default", "False", "Whether", "to", "copy", "the", "blocks" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L638-L646
[ "def", "get_bool_data", "(", "self", ",", "copy", "=", "False", ")", ":", "self", ".", "_consolidate_inplace", "(", ")", "return", "self", ".", "combine", "(", "[", "b", "for", "b", "in", "self", ".", "blocks", "if", "b", ".", "is_bool", "]", ",", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.get_numeric_data
Parameters ---------- copy : boolean, default False Whether to copy the blocks
pandas/core/internals/managers.py
def get_numeric_data(self, copy=False): """ Parameters ---------- copy : boolean, default False Whether to copy the blocks """ self._consolidate_inplace() return self.combine([b for b in self.blocks if b.is_numeric], copy)
def get_numeric_data(self, copy=False): """ Parameters ---------- copy : boolean, default False Whether to copy the blocks """ self._consolidate_inplace() return self.combine([b for b in self.blocks if b.is_numeric], copy)
[ "Parameters", "----------", "copy", ":", "boolean", "default", "False", "Whether", "to", "copy", "the", "blocks" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L648-L656
[ "def", "get_numeric_data", "(", "self", ",", "copy", "=", "False", ")", ":", "self", ".", "_consolidate_inplace", "(", ")", "return", "self", ".", "combine", "(", "[", "b", "for", "b", "in", "self", ".", "blocks", "if", "b", ".", "is_numeric", "]", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.combine
return a new manager with the blocks
pandas/core/internals/managers.py
def combine(self, blocks, copy=True): """ return a new manager with the blocks """ if len(blocks) == 0: return self.make_empty() # FIXME: optimization potential indexer = np.sort(np.concatenate([b.mgr_locs.as_array for b in blocks]))...
def combine(self, blocks, copy=True): """ return a new manager with the blocks """ if len(blocks) == 0: return self.make_empty() # FIXME: optimization potential indexer = np.sort(np.concatenate([b.mgr_locs.as_array for b in blocks]))...
[ "return", "a", "new", "manager", "with", "the", "blocks" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L658-L678
[ "def", "combine", "(", "self", ",", "blocks", ",", "copy", "=", "True", ")", ":", "if", "len", "(", "blocks", ")", "==", "0", ":", "return", "self", ".", "make_empty", "(", ")", "# FIXME: optimization potential", "indexer", "=", "np", ".", "sort", "(",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.copy
Make deep or shallow copy of BlockManager Parameters ---------- deep : boolean o rstring, default True If False, return shallow copy (do not copy data) If 'all', copy data and a deep copy of the index Returns ------- copy : BlockManager
pandas/core/internals/managers.py
def copy(self, deep=True): """ Make deep or shallow copy of BlockManager Parameters ---------- deep : boolean o rstring, default True If False, return shallow copy (do not copy data) If 'all', copy data and a deep copy of the index Returns ...
def copy(self, deep=True): """ Make deep or shallow copy of BlockManager Parameters ---------- deep : boolean o rstring, default True If False, return shallow copy (do not copy data) If 'all', copy data and a deep copy of the index Returns ...
[ "Make", "deep", "or", "shallow", "copy", "of", "BlockManager" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L706-L730
[ "def", "copy", "(", "self", ",", "deep", "=", "True", ")", ":", "# this preserves the notion of view copying of axes", "if", "deep", ":", "if", "deep", "==", "'all'", ":", "copy", "=", "lambda", "ax", ":", "ax", ".", "copy", "(", "deep", "=", "True", ")"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.as_array
Convert the blockmanager data into an numpy array. Parameters ---------- transpose : boolean, default False If True, transpose the return array items : list of strings or None Names of block items that will be included in the returned array. ``None`` ...
pandas/core/internals/managers.py
def as_array(self, transpose=False, items=None): """Convert the blockmanager data into an numpy array. Parameters ---------- transpose : boolean, default False If True, transpose the return array items : list of strings or None Names of block items that w...
def as_array(self, transpose=False, items=None): """Convert the blockmanager data into an numpy array. Parameters ---------- transpose : boolean, default False If True, transpose the return array items : list of strings or None Names of block items that w...
[ "Convert", "the", "blockmanager", "data", "into", "an", "numpy", "array", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L732-L766
[ "def", "as_array", "(", "self", ",", "transpose", "=", "False", ",", "items", "=", "None", ")", ":", "if", "len", "(", "self", ".", "blocks", ")", "==", "0", ":", "arr", "=", "np", ".", "empty", "(", "self", ".", "shape", ",", "dtype", "=", "fl...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager._interleave
Return ndarray from blocks with specified item order Items must be contained in the blocks
pandas/core/internals/managers.py
def _interleave(self): """ Return ndarray from blocks with specified item order Items must be contained in the blocks """ from pandas.core.dtypes.common import is_sparse dtype = _interleaved_dtype(self.blocks) # TODO: https://github.com/pandas-dev/pandas/issues/2...
def _interleave(self): """ Return ndarray from blocks with specified item order Items must be contained in the blocks """ from pandas.core.dtypes.common import is_sparse dtype = _interleaved_dtype(self.blocks) # TODO: https://github.com/pandas-dev/pandas/issues/2...
[ "Return", "ndarray", "from", "blocks", "with", "specified", "item", "order", "Items", "must", "be", "contained", "in", "the", "blocks" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L768-L795
[ "def", "_interleave", "(", "self", ")", ":", "from", "pandas", ".", "core", ".", "dtypes", ".", "common", "import", "is_sparse", "dtype", "=", "_interleaved_dtype", "(", "self", ".", "blocks", ")", "# TODO: https://github.com/pandas-dev/pandas/issues/22791", "# Give...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.to_dict
Return a dict of str(dtype) -> BlockManager Parameters ---------- copy : boolean, default True Returns ------- values : a dict of dtype -> BlockManager Notes ----- This consolidates based on str(dtype)
pandas/core/internals/managers.py
def to_dict(self, copy=True): """ Return a dict of str(dtype) -> BlockManager Parameters ---------- copy : boolean, default True Returns ------- values : a dict of dtype -> BlockManager Notes ----- This consolidates based on str(...
def to_dict(self, copy=True): """ Return a dict of str(dtype) -> BlockManager Parameters ---------- copy : boolean, default True Returns ------- values : a dict of dtype -> BlockManager Notes ----- This consolidates based on str(...
[ "Return", "a", "dict", "of", "str", "(", "dtype", ")", "-", ">", "BlockManager" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L797-L820
[ "def", "to_dict", "(", "self", ",", "copy", "=", "True", ")", ":", "self", ".", "_consolidate_inplace", "(", ")", "bd", "=", "{", "}", "for", "b", "in", "self", ".", "blocks", ":", "bd", ".", "setdefault", "(", "str", "(", "b", ".", "dtype", ")",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.fast_xs
get a cross sectional for a given location in the items ; handle dups return the result, is *could* be a view in the case of a single block
pandas/core/internals/managers.py
def fast_xs(self, loc): """ get a cross sectional for a given location in the items ; handle dups return the result, is *could* be a view in the case of a single block """ if len(self.blocks) == 1: return self.blocks[0].iget((slice(None), loc)) ...
def fast_xs(self, loc): """ get a cross sectional for a given location in the items ; handle dups return the result, is *could* be a view in the case of a single block """ if len(self.blocks) == 1: return self.blocks[0].iget((slice(None), loc)) ...
[ "get", "a", "cross", "sectional", "for", "a", "given", "location", "in", "the", "items", ";", "handle", "dups" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L864-L905
[ "def", "fast_xs", "(", "self", ",", "loc", ")", ":", "if", "len", "(", "self", ".", "blocks", ")", "==", "1", ":", "return", "self", ".", "blocks", "[", "0", "]", ".", "iget", "(", "(", "slice", "(", "None", ")", ",", "loc", ")", ")", "items"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.consolidate
Join together blocks having same dtype Returns ------- y : BlockManager
pandas/core/internals/managers.py
def consolidate(self): """ Join together blocks having same dtype Returns ------- y : BlockManager """ if self.is_consolidated(): return self bm = self.__class__(self.blocks, self.axes) bm._is_consolidated = False bm._consolid...
def consolidate(self): """ Join together blocks having same dtype Returns ------- y : BlockManager """ if self.is_consolidated(): return self bm = self.__class__(self.blocks, self.axes) bm._is_consolidated = False bm._consolid...
[ "Join", "together", "blocks", "having", "same", "dtype" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L907-L921
[ "def", "consolidate", "(", "self", ")", ":", "if", "self", ".", "is_consolidated", "(", ")", ":", "return", "self", "bm", "=", "self", ".", "__class__", "(", "self", ".", "blocks", ",", "self", ".", "axes", ")", "bm", ".", "_is_consolidated", "=", "F...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.get
Return values for selected item (ndarray or BlockManager).
pandas/core/internals/managers.py
def get(self, item, fastpath=True): """ Return values for selected item (ndarray or BlockManager). """ if self.items.is_unique: if not isna(item): loc = self.items.get_loc(item) else: indexer = np.arange(len(self.items))[isna(self....
def get(self, item, fastpath=True): """ Return values for selected item (ndarray or BlockManager). """ if self.items.is_unique: if not isna(item): loc = self.items.get_loc(item) else: indexer = np.arange(len(self.items))[isna(self....
[ "Return", "values", "for", "selected", "item", "(", "ndarray", "or", "BlockManager", ")", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L930-L957
[ "def", "get", "(", "self", ",", "item", ",", "fastpath", "=", "True", ")", ":", "if", "self", ".", "items", ".", "is_unique", ":", "if", "not", "isna", "(", "item", ")", ":", "loc", "=", "self", ".", "items", ".", "get_loc", "(", "item", ")", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.iget
Return the data as a SingleBlockManager if fastpath=True and possible Otherwise return as a ndarray
pandas/core/internals/managers.py
def iget(self, i, fastpath=True): """ Return the data as a SingleBlockManager if fastpath=True and possible Otherwise return as a ndarray """ block = self.blocks[self._blknos[i]] values = block.iget(self._blklocs[i]) if not fastpath or not block._box_to_block_val...
def iget(self, i, fastpath=True): """ Return the data as a SingleBlockManager if fastpath=True and possible Otherwise return as a ndarray """ block = self.blocks[self._blknos[i]] values = block.iget(self._blklocs[i]) if not fastpath or not block._box_to_block_val...
[ "Return", "the", "data", "as", "a", "SingleBlockManager", "if", "fastpath", "=", "True", "and", "possible" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L959-L975
[ "def", "iget", "(", "self", ",", "i", ",", "fastpath", "=", "True", ")", ":", "block", "=", "self", ".", "blocks", "[", "self", ".", "_blknos", "[", "i", "]", "]", "values", "=", "block", ".", "iget", "(", "self", ".", "_blklocs", "[", "i", "]"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.delete
Delete selected item (items if non-unique) in-place.
pandas/core/internals/managers.py
def delete(self, item): """ Delete selected item (items if non-unique) in-place. """ indexer = self.items.get_loc(item) is_deleted = np.zeros(self.shape[0], dtype=np.bool_) is_deleted[indexer] = True ref_loc_offset = -is_deleted.cumsum() is_blk_deleted =...
def delete(self, item): """ Delete selected item (items if non-unique) in-place. """ indexer = self.items.get_loc(item) is_deleted = np.zeros(self.shape[0], dtype=np.bool_) is_deleted[indexer] = True ref_loc_offset = -is_deleted.cumsum() is_blk_deleted =...
[ "Delete", "selected", "item", "(", "items", "if", "non", "-", "unique", ")", "in", "-", "place", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L977-L1013
[ "def", "delete", "(", "self", ",", "item", ")", ":", "indexer", "=", "self", ".", "items", ".", "get_loc", "(", "item", ")", "is_deleted", "=", "np", ".", "zeros", "(", "self", ".", "shape", "[", "0", "]", ",", "dtype", "=", "np", ".", "bool_", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.set
Set new item in-place. Does not consolidate. Adds new Block if not contained in the current set of items
pandas/core/internals/managers.py
def set(self, item, value): """ Set new item in-place. Does not consolidate. Adds new Block if not contained in the current set of items """ # FIXME: refactor, clearly separate broadcasting & zip-like assignment # can prob also fix the various if tests for sparse/c...
def set(self, item, value): """ Set new item in-place. Does not consolidate. Adds new Block if not contained in the current set of items """ # FIXME: refactor, clearly separate broadcasting & zip-like assignment # can prob also fix the various if tests for sparse/c...
[ "Set", "new", "item", "in", "-", "place", ".", "Does", "not", "consolidate", ".", "Adds", "new", "Block", "if", "not", "contained", "in", "the", "current", "set", "of", "items" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1015-L1128
[ "def", "set", "(", "self", ",", "item", ",", "value", ")", ":", "# FIXME: refactor, clearly separate broadcasting & zip-like assignment", "# can prob also fix the various if tests for sparse/categorical", "# TODO(EA): Remove an is_extension_ when all extension types satisfy", "# the...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.insert
Insert item at selected position. Parameters ---------- loc : int item : hashable value : array_like allow_duplicates: bool If False, trying to insert non-unique item will raise
pandas/core/internals/managers.py
def insert(self, loc, item, value, allow_duplicates=False): """ Insert item at selected position. Parameters ---------- loc : int item : hashable value : array_like allow_duplicates: bool If False, trying to insert non-unique item will raise ...
def insert(self, loc, item, value, allow_duplicates=False): """ Insert item at selected position. Parameters ---------- loc : int item : hashable value : array_like allow_duplicates: bool If False, trying to insert non-unique item will raise ...
[ "Insert", "item", "at", "selected", "position", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1130-L1180
[ "def", "insert", "(", "self", ",", "loc", ",", "item", ",", "value", ",", "allow_duplicates", "=", "False", ")", ":", "if", "not", "allow_duplicates", "and", "item", "in", "self", ".", "items", ":", "# Should this be a different kind of error??", "raise", "Val...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.reindex_axis
Conform block manager to new index.
pandas/core/internals/managers.py
def reindex_axis(self, new_index, axis, method=None, limit=None, fill_value=None, copy=True): """ Conform block manager to new index. """ new_index = ensure_index(new_index) new_index, indexer = self.axes[axis].reindex(new_index, method=method, ...
def reindex_axis(self, new_index, axis, method=None, limit=None, fill_value=None, copy=True): """ Conform block manager to new index. """ new_index = ensure_index(new_index) new_index, indexer = self.axes[axis].reindex(new_index, method=method, ...
[ "Conform", "block", "manager", "to", "new", "index", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1182-L1192
[ "def", "reindex_axis", "(", "self", ",", "new_index", ",", "axis", ",", "method", "=", "None", ",", "limit", "=", "None", ",", "fill_value", "=", "None", ",", "copy", "=", "True", ")", ":", "new_index", "=", "ensure_index", "(", "new_index", ")", "new_...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.reindex_indexer
Parameters ---------- new_axis : Index indexer : ndarray of int64 or None axis : int fill_value : object allow_dups : bool pandas-indexer with -1's only.
pandas/core/internals/managers.py
def reindex_indexer(self, new_axis, indexer, axis, fill_value=None, allow_dups=False, copy=True): """ Parameters ---------- new_axis : Index indexer : ndarray of int64 or None axis : int fill_value : object allow_dups : bool ...
def reindex_indexer(self, new_axis, indexer, axis, fill_value=None, allow_dups=False, copy=True): """ Parameters ---------- new_axis : Index indexer : ndarray of int64 or None axis : int fill_value : object allow_dups : bool ...
[ "Parameters", "----------", "new_axis", ":", "Index", "indexer", ":", "ndarray", "of", "int64", "or", "None", "axis", ":", "int", "fill_value", ":", "object", "allow_dups", ":", "bool" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1194-L1235
[ "def", "reindex_indexer", "(", "self", ",", "new_axis", ",", "indexer", ",", "axis", ",", "fill_value", "=", "None", ",", "allow_dups", "=", "False", ",", "copy", "=", "True", ")", ":", "if", "indexer", "is", "None", ":", "if", "new_axis", "is", "self"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager._slice_take_blocks_ax0
Slice/take blocks along axis=0. Overloaded for SingleBlock Returns ------- new_blocks : list of Block
pandas/core/internals/managers.py
def _slice_take_blocks_ax0(self, slice_or_indexer, fill_tuple=None): """ Slice/take blocks along axis=0. Overloaded for SingleBlock Returns ------- new_blocks : list of Block """ allow_fill = fill_tuple is not None sl_type, slobj, sllen = _pre...
def _slice_take_blocks_ax0(self, slice_or_indexer, fill_tuple=None): """ Slice/take blocks along axis=0. Overloaded for SingleBlock Returns ------- new_blocks : list of Block """ allow_fill = fill_tuple is not None sl_type, slobj, sllen = _pre...
[ "Slice", "/", "take", "blocks", "along", "axis", "=", "0", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1237-L1310
[ "def", "_slice_take_blocks_ax0", "(", "self", ",", "slice_or_indexer", ",", "fill_tuple", "=", "None", ")", ":", "allow_fill", "=", "fill_tuple", "is", "not", "None", "sl_type", ",", "slobj", ",", "sllen", "=", "_preprocess_slice_or_indexer", "(", "slice_or_indexe...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.take
Take items along any axis.
pandas/core/internals/managers.py
def take(self, indexer, axis=1, verify=True, convert=True): """ Take items along any axis. """ self._consolidate_inplace() indexer = (np.arange(indexer.start, indexer.stop, indexer.step, dtype='int64') if isinstance(indexer, slice) ...
def take(self, indexer, axis=1, verify=True, convert=True): """ Take items along any axis. """ self._consolidate_inplace() indexer = (np.arange(indexer.start, indexer.stop, indexer.step, dtype='int64') if isinstance(indexer, slice) ...
[ "Take", "items", "along", "any", "axis", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1325-L1346
[ "def", "take", "(", "self", ",", "indexer", ",", "axis", "=", "1", ",", "verify", "=", "True", ",", "convert", "=", "True", ")", ":", "self", ".", "_consolidate_inplace", "(", ")", "indexer", "=", "(", "np", ".", "arange", "(", "indexer", ".", "sta...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BlockManager.unstack
Return a blockmanager with all blocks unstacked. Parameters ---------- unstacker_func : callable A (partially-applied) ``pd.core.reshape._Unstacker`` class. fill_value : Any fill_value for newly introduced missing values. Returns ------- ...
pandas/core/internals/managers.py
def unstack(self, unstacker_func, fill_value): """Return a blockmanager with all blocks unstacked. Parameters ---------- unstacker_func : callable A (partially-applied) ``pd.core.reshape._Unstacker`` class. fill_value : Any fill_value for newly introduced...
def unstack(self, unstacker_func, fill_value): """Return a blockmanager with all blocks unstacked. Parameters ---------- unstacker_func : callable A (partially-applied) ``pd.core.reshape._Unstacker`` class. fill_value : Any fill_value for newly introduced...
[ "Return", "a", "blockmanager", "with", "all", "blocks", "unstacked", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1392-L1428
[ "def", "unstack", "(", "self", ",", "unstacker_func", ",", "fill_value", ")", ":", "n_rows", "=", "self", ".", "shape", "[", "-", "1", "]", "dummy", "=", "unstacker_func", "(", "np", ".", "empty", "(", "(", "0", ",", "0", ")", ")", ",", "value_colu...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SingleBlockManager.delete
Delete single item from SingleBlockManager. Ensures that self.blocks doesn't become empty.
pandas/core/internals/managers.py
def delete(self, item): """ Delete single item from SingleBlockManager. Ensures that self.blocks doesn't become empty. """ loc = self.items.get_loc(item) self._block.delete(loc) self.axes[0] = self.axes[0].delete(loc)
def delete(self, item): """ Delete single item from SingleBlockManager. Ensures that self.blocks doesn't become empty. """ loc = self.items.get_loc(item) self._block.delete(loc) self.axes[0] = self.axes[0].delete(loc)
[ "Delete", "single", "item", "from", "SingleBlockManager", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1577-L1585
[ "def", "delete", "(", "self", ",", "item", ")", ":", "loc", "=", "self", ".", "items", ".", "get_loc", "(", "item", ")", "self", ".", "_block", ".", "delete", "(", "loc", ")", "self", ".", "axes", "[", "0", "]", "=", "self", ".", "axes", "[", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SingleBlockManager.concat
Concatenate a list of SingleBlockManagers into a single SingleBlockManager. Used for pd.concat of Series objects with axis=0. Parameters ---------- to_concat : list of SingleBlockManagers new_axis : Index of the result Returns ------- SingleBloc...
pandas/core/internals/managers.py
def concat(self, to_concat, new_axis): """ Concatenate a list of SingleBlockManagers into a single SingleBlockManager. Used for pd.concat of Series objects with axis=0. Parameters ---------- to_concat : list of SingleBlockManagers new_axis : Index of the...
def concat(self, to_concat, new_axis): """ Concatenate a list of SingleBlockManagers into a single SingleBlockManager. Used for pd.concat of Series objects with axis=0. Parameters ---------- to_concat : list of SingleBlockManagers new_axis : Index of the...
[ "Concatenate", "a", "list", "of", "SingleBlockManagers", "into", "a", "single", "SingleBlockManager", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1594-L1630
[ "def", "concat", "(", "self", ",", "to_concat", ",", "new_axis", ")", ":", "non_empties", "=", "[", "x", "for", "x", "in", "to_concat", "if", "len", "(", "x", ")", ">", "0", "]", "# check if all series are of the same block type:", "if", "len", "(", "non_e...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SparseSeries.from_array
Construct SparseSeries from array. .. deprecated:: 0.23.0 Use the pd.SparseSeries(..) constructor instead.
pandas/core/sparse/series.py
def from_array(cls, arr, index=None, name=None, copy=False, fill_value=None, fastpath=False): """Construct SparseSeries from array. .. deprecated:: 0.23.0 Use the pd.SparseSeries(..) constructor instead. """ warnings.warn("'from_array' is deprecated and wi...
def from_array(cls, arr, index=None, name=None, copy=False, fill_value=None, fastpath=False): """Construct SparseSeries from array. .. deprecated:: 0.23.0 Use the pd.SparseSeries(..) constructor instead. """ warnings.warn("'from_array' is deprecated and wi...
[ "Construct", "SparseSeries", "from", "array", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L181-L192
[ "def", "from_array", "(", "cls", ",", "arr", ",", "index", "=", "None", ",", "name", "=", "None", ",", "copy", "=", "False", ",", "fill_value", "=", "None", ",", "fastpath", "=", "False", ")", ":", "warnings", ".", "warn", "(", "\"'from_array' is depre...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SparseSeries.as_sparse_array
return my self as a sparse array, do not copy by default
pandas/core/sparse/series.py
def as_sparse_array(self, kind=None, fill_value=None, copy=False): """ return my self as a sparse array, do not copy by default """ if fill_value is None: fill_value = self.fill_value if kind is None: kind = self.kind return SparseArray(self.values, sparse_index=...
def as_sparse_array(self, kind=None, fill_value=None, copy=False): """ return my self as a sparse array, do not copy by default """ if fill_value is None: fill_value = self.fill_value if kind is None: kind = self.kind return SparseArray(self.values, sparse_index=...
[ "return", "my", "self", "as", "a", "sparse", "array", "do", "not", "copy", "by", "default" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L210-L218
[ "def", "as_sparse_array", "(", "self", ",", "kind", "=", "None", ",", "fill_value", "=", "None", ",", "copy", "=", "False", ")", ":", "if", "fill_value", "is", "None", ":", "fill_value", "=", "self", ".", "fill_value", "if", "kind", "is", "None", ":", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SparseSeries._reduce
perform a reduction operation
pandas/core/sparse/series.py
def _reduce(self, op, name, axis=0, skipna=True, numeric_only=None, filter_type=None, **kwds): """ perform a reduction operation """ return op(self.get_values(), skipna=skipna, **kwds)
def _reduce(self, op, name, axis=0, skipna=True, numeric_only=None, filter_type=None, **kwds): """ perform a reduction operation """ return op(self.get_values(), skipna=skipna, **kwds)
[ "perform", "a", "reduction", "operation" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L227-L230
[ "def", "_reduce", "(", "self", ",", "op", ",", "name", ",", "axis", "=", "0", ",", "skipna", "=", "True", ",", "numeric_only", "=", "None", ",", "filter_type", "=", "None", ",", "*", "*", "kwds", ")", ":", "return", "op", "(", "self", ".", "get_v...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SparseSeries._ixs
Return the i-th value or values in the SparseSeries by location Parameters ---------- i : int, slice, or sequence of integers Returns ------- value : scalar (int) or Series (slice, sequence)
pandas/core/sparse/series.py
def _ixs(self, i, axis=0): """ Return the i-th value or values in the SparseSeries by location Parameters ---------- i : int, slice, or sequence of integers Returns ------- value : scalar (int) or Series (slice, sequence) """ label = self...
def _ixs(self, i, axis=0): """ Return the i-th value or values in the SparseSeries by location Parameters ---------- i : int, slice, or sequence of integers Returns ------- value : scalar (int) or Series (slice, sequence) """ label = self...
[ "Return", "the", "i", "-", "th", "value", "or", "values", "in", "the", "SparseSeries", "by", "location" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L268-L284
[ "def", "_ixs", "(", "self", ",", "i", ",", "axis", "=", "0", ")", ":", "label", "=", "self", ".", "index", "[", "i", "]", "if", "isinstance", "(", "label", ",", "Index", ")", ":", "return", "self", ".", "take", "(", "i", ",", "axis", "=", "ax...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SparseSeries.abs
Return an object with absolute value taken. Only applicable to objects that are all numeric Returns ------- abs: same type as caller
pandas/core/sparse/series.py
def abs(self): """ Return an object with absolute value taken. Only applicable to objects that are all numeric Returns ------- abs: same type as caller """ return self._constructor(np.abs(self.values), index=self.index).__...
def abs(self): """ Return an object with absolute value taken. Only applicable to objects that are all numeric Returns ------- abs: same type as caller """ return self._constructor(np.abs(self.values), index=self.index).__...
[ "Return", "an", "object", "with", "absolute", "value", "taken", ".", "Only", "applicable", "to", "objects", "that", "are", "all", "numeric" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L308-L318
[ "def", "abs", "(", "self", ")", ":", "return", "self", ".", "_constructor", "(", "np", ".", "abs", "(", "self", ".", "values", ")", ",", "index", "=", "self", ".", "index", ")", ".", "__finalize__", "(", "self", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SparseSeries.get
Returns value occupying requested label, default to specified missing value if not present. Analogous to dict.get Parameters ---------- label : object Label value looking for default : object, optional Value to return if label not in index Return...
pandas/core/sparse/series.py
def get(self, label, default=None): """ Returns value occupying requested label, default to specified missing value if not present. Analogous to dict.get Parameters ---------- label : object Label value looking for default : object, optional ...
def get(self, label, default=None): """ Returns value occupying requested label, default to specified missing value if not present. Analogous to dict.get Parameters ---------- label : object Label value looking for default : object, optional ...
[ "Returns", "value", "occupying", "requested", "label", "default", "to", "specified", "missing", "value", "if", "not", "present", ".", "Analogous", "to", "dict", ".", "get" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L320-L340
[ "def", "get", "(", "self", ",", "label", ",", "default", "=", "None", ")", ":", "if", "label", "in", "self", ".", "index", ":", "loc", "=", "self", ".", "index", ".", "get_loc", "(", "label", ")", "return", "self", ".", "_get_val_at", "(", "loc", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SparseSeries.get_value
Retrieve single value at passed index label .. deprecated:: 0.21.0 Please use .at[] or .iat[] accessors. Parameters ---------- index : label takeable : interpret the index as indexers, default False Returns ------- value : scalar value
pandas/core/sparse/series.py
def get_value(self, label, takeable=False): """ Retrieve single value at passed index label .. deprecated:: 0.21.0 Please use .at[] or .iat[] accessors. Parameters ---------- index : label takeable : interpret the index as indexers, default False ...
def get_value(self, label, takeable=False): """ Retrieve single value at passed index label .. deprecated:: 0.21.0 Please use .at[] or .iat[] accessors. Parameters ---------- index : label takeable : interpret the index as indexers, default False ...
[ "Retrieve", "single", "value", "at", "passed", "index", "label" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L342-L364
[ "def", "get_value", "(", "self", ",", "label", ",", "takeable", "=", "False", ")", ":", "warnings", ".", "warn", "(", "\"get_value is deprecated and will be removed \"", "\"in a future release. Please use \"", "\".at[] or .iat[] accessors instead\"", ",", "FutureWarning", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SparseSeries.set_value
Quickly set single value at passed label. If label is not contained, a new object is created with the label placed at the end of the result index .. deprecated:: 0.21.0 Please use .at[] or .iat[] accessors. Parameters ---------- label : object Parti...
pandas/core/sparse/series.py
def set_value(self, label, value, takeable=False): """ Quickly set single value at passed label. If label is not contained, a new object is created with the label placed at the end of the result index .. deprecated:: 0.21.0 Please use .at[] or .iat[] accessors. ...
def set_value(self, label, value, takeable=False): """ Quickly set single value at passed label. If label is not contained, a new object is created with the label placed at the end of the result index .. deprecated:: 0.21.0 Please use .at[] or .iat[] accessors. ...
[ "Quickly", "set", "single", "value", "at", "passed", "label", ".", "If", "label", "is", "not", "contained", "a", "new", "object", "is", "created", "with", "the", "label", "placed", "at", "the", "end", "of", "the", "result", "index" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L371-L402
[ "def", "set_value", "(", "self", ",", "label", ",", "value", ",", "takeable", "=", "False", ")", ":", "warnings", ".", "warn", "(", "\"set_value is deprecated and will be removed \"", "\"in a future release. Please use \"", "\".at[] or .iat[] accessors instead\"", ",", "F...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SparseSeries.to_dense
Convert SparseSeries to a Series. Returns ------- s : Series
pandas/core/sparse/series.py
def to_dense(self): """ Convert SparseSeries to a Series. Returns ------- s : Series """ return Series(self.values.to_dense(), index=self.index, name=self.name)
def to_dense(self): """ Convert SparseSeries to a Series. Returns ------- s : Series """ return Series(self.values.to_dense(), index=self.index, name=self.name)
[ "Convert", "SparseSeries", "to", "a", "Series", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L434-L443
[ "def", "to_dense", "(", "self", ")", ":", "return", "Series", "(", "self", ".", "values", ".", "to_dense", "(", ")", ",", "index", "=", "self", ".", "index", ",", "name", "=", "self", ".", "name", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SparseSeries.copy
Make a copy of the SparseSeries. Only the actual sparse values need to be copied
pandas/core/sparse/series.py
def copy(self, deep=True): """ Make a copy of the SparseSeries. Only the actual sparse values need to be copied """ # TODO: https://github.com/pandas-dev/pandas/issues/22314 # We skip the block manager till that is resolved. new_data = self.values.copy(deep=deep) ...
def copy(self, deep=True): """ Make a copy of the SparseSeries. Only the actual sparse values need to be copied """ # TODO: https://github.com/pandas-dev/pandas/issues/22314 # We skip the block manager till that is resolved. new_data = self.values.copy(deep=deep) ...
[ "Make", "a", "copy", "of", "the", "SparseSeries", ".", "Only", "the", "actual", "sparse", "values", "need", "to", "be", "copied" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L449-L460
[ "def", "copy", "(", "self", ",", "deep", "=", "True", ")", ":", "# TODO: https://github.com/pandas-dev/pandas/issues/22314", "# We skip the block manager till that is resolved.", "new_data", "=", "self", ".", "values", ".", "copy", "(", "deep", "=", "deep", ")", "retu...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SparseSeries.sparse_reindex
Conform sparse values to new SparseIndex Parameters ---------- new_index : {BlockIndex, IntIndex} Returns ------- reindexed : SparseSeries
pandas/core/sparse/series.py
def sparse_reindex(self, new_index): """ Conform sparse values to new SparseIndex Parameters ---------- new_index : {BlockIndex, IntIndex} Returns ------- reindexed : SparseSeries """ if not isinstance(new_index, splib.SparseIndex): ...
def sparse_reindex(self, new_index): """ Conform sparse values to new SparseIndex Parameters ---------- new_index : {BlockIndex, IntIndex} Returns ------- reindexed : SparseSeries """ if not isinstance(new_index, splib.SparseIndex): ...
[ "Conform", "sparse", "values", "to", "new", "SparseIndex" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L470-L490
[ "def", "sparse_reindex", "(", "self", ",", "new_index", ")", ":", "if", "not", "isinstance", "(", "new_index", ",", "splib", ".", "SparseIndex", ")", ":", "raise", "TypeError", "(", "\"new index must be a SparseIndex\"", ")", "values", "=", "self", ".", "value...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SparseSeries.cumsum
Cumulative sum of non-NA/null values. When performing the cumulative summation, any non-NA/null values will be skipped. The resulting SparseSeries will preserve the locations of NaN values, but the fill value will be `np.nan` regardless. Parameters ---------- axis : {0}...
pandas/core/sparse/series.py
def cumsum(self, axis=0, *args, **kwargs): """ Cumulative sum of non-NA/null values. When performing the cumulative summation, any non-NA/null values will be skipped. The resulting SparseSeries will preserve the locations of NaN values, but the fill value will be `np.nan` regard...
def cumsum(self, axis=0, *args, **kwargs): """ Cumulative sum of non-NA/null values. When performing the cumulative summation, any non-NA/null values will be skipped. The resulting SparseSeries will preserve the locations of NaN values, but the fill value will be `np.nan` regard...
[ "Cumulative", "sum", "of", "non", "-", "NA", "/", "null", "values", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L492-L517
[ "def", "cumsum", "(", "self", ",", "axis", "=", "0", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "nv", ".", "validate_cumsum", "(", "args", ",", "kwargs", ")", "# Validate axis", "if", "axis", "is", "not", "None", ":", "self", ".", "_get_a...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SparseSeries.dropna
Analogous to Series.dropna. If fill_value=NaN, returns a dense Series
pandas/core/sparse/series.py
def dropna(self, axis=0, inplace=False, **kwargs): """ Analogous to Series.dropna. If fill_value=NaN, returns a dense Series """ # TODO: make more efficient # Validate axis self._get_axis_number(axis or 0) dense_valid = self.to_dense().dropna() if inplace:...
def dropna(self, axis=0, inplace=False, **kwargs): """ Analogous to Series.dropna. If fill_value=NaN, returns a dense Series """ # TODO: make more efficient # Validate axis self._get_axis_number(axis or 0) dense_valid = self.to_dense().dropna() if inplace:...
[ "Analogous", "to", "Series", ".", "dropna", ".", "If", "fill_value", "=", "NaN", "returns", "a", "dense", "Series" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L537-L552
[ "def", "dropna", "(", "self", ",", "axis", "=", "0", ",", "inplace", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# TODO: make more efficient", "# Validate axis", "self", ".", "_get_axis_number", "(", "axis", "or", "0", ")", "dense_valid", "=", "self"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SparseSeries.combine_first
Combine Series values, choosing the calling Series's values first. Result index will be the union of the two indexes Parameters ---------- other : Series Returns ------- y : Series
pandas/core/sparse/series.py
def combine_first(self, other): """ Combine Series values, choosing the calling Series's values first. Result index will be the union of the two indexes Parameters ---------- other : Series Returns ------- y : Series """ if isinst...
def combine_first(self, other): """ Combine Series values, choosing the calling Series's values first. Result index will be the union of the two indexes Parameters ---------- other : Series Returns ------- y : Series """ if isinst...
[ "Combine", "Series", "values", "choosing", "the", "calling", "Series", "s", "values", "first", ".", "Result", "index", "will", "be", "the", "union", "of", "the", "two", "indexes" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L554-L571
[ "def", "combine_first", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "SparseSeries", ")", ":", "other", "=", "other", ".", "to_dense", "(", ")", "dense_combined", "=", "self", ".", "to_dense", "(", ")", ".", "combine_first"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_maybe_cache
Create a cache of unique dates from an array of dates Parameters ---------- arg : integer, float, string, datetime, list, tuple, 1-d array, Series format : string Strftime format to parse time cache : boolean True attempts to create a cache of converted values convert_listlike :...
pandas/core/tools/datetimes.py
def _maybe_cache(arg, format, cache, convert_listlike): """ Create a cache of unique dates from an array of dates Parameters ---------- arg : integer, float, string, datetime, list, tuple, 1-d array, Series format : string Strftime format to parse time cache : boolean True a...
def _maybe_cache(arg, format, cache, convert_listlike): """ Create a cache of unique dates from an array of dates Parameters ---------- arg : integer, float, string, datetime, list, tuple, 1-d array, Series format : string Strftime format to parse time cache : boolean True a...
[ "Create", "a", "cache", "of", "unique", "dates", "from", "an", "array", "of", "dates" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/tools/datetimes.py#L31-L60
[ "def", "_maybe_cache", "(", "arg", ",", "format", ",", "cache", ",", "convert_listlike", ")", ":", "from", "pandas", "import", "Series", "cache_array", "=", "Series", "(", ")", "if", "cache", ":", "# Perform a quicker unique check", "from", "pandas", "import", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_convert_and_box_cache
Convert array of dates with a cache and box the result Parameters ---------- arg : integer, float, string, datetime, list, tuple, 1-d array, Series cache_array : Series Cache of converted, unique dates box : boolean True boxes result as an Index-like, False returns an ndarray er...
pandas/core/tools/datetimes.py
def _convert_and_box_cache(arg, cache_array, box, errors, name=None): """ Convert array of dates with a cache and box the result Parameters ---------- arg : integer, float, string, datetime, list, tuple, 1-d array, Series cache_array : Series Cache of converted, unique dates box : b...
def _convert_and_box_cache(arg, cache_array, box, errors, name=None): """ Convert array of dates with a cache and box the result Parameters ---------- arg : integer, float, string, datetime, list, tuple, 1-d array, Series cache_array : Series Cache of converted, unique dates box : b...
[ "Convert", "array", "of", "dates", "with", "a", "cache", "and", "box", "the", "result" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/tools/datetimes.py#L63-L94
[ "def", "_convert_and_box_cache", "(", "arg", ",", "cache_array", ",", "box", ",", "errors", ",", "name", "=", "None", ")", ":", "from", "pandas", "import", "Series", ",", "DatetimeIndex", ",", "Index", "result", "=", "Series", "(", "arg", ")", ".", "map"...
9feb3ad92cc0397a04b665803a49299ee7aa1037