Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def get_atom_coltype(self, kind=None): if kind is None: kind = self.kind if self.kind.startswith('uint'): col_name = "UInt{name}Col".format(name=kind[4:]) else: col_name = "{name}Col".format(name=kind.capit...
[ " return the PyTables column class for this column " ]
Please provide a description of the function:def validate_attr(self, append): if append: existing_fields = getattr(self.attrs, self.kind_attr, None) if (existing_fields is not None and existing_fields != list(self.values)): raise ValueError("a...
[ "validate that we have the same order as the existing & same dtype" ]
Please provide a description of the function:def convert(self, values, nan_rep, encoding, errors): # values is a recarray if values.dtype.fields is not None: values = values[self.cname] self.set_data(values) # use the meta if needed meta = _ensure_decoded(...
[ "set the data from this selection (and convert to the correct dtype\n if we can)\n " ]
Please provide a description of the function:def get_attr(self): self.values = getattr(self.attrs, self.kind_attr, None) self.dtype = getattr(self.attrs, self.dtype_attr, None) self.meta = getattr(self.attrs, self.meta_attr, None) self.set_kind()
[ " get the data for this column " ]
Please provide a description of the function:def set_attr(self): setattr(self.attrs, self.kind_attr, self.values) setattr(self.attrs, self.meta_attr, self.meta) if self.dtype is not None: setattr(self.attrs, self.dtype_attr, self.dtype)
[ " set the data for this column " ]
Please provide a description of the function:def set_version(self): version = _ensure_decoded( getattr(self.group._v_attrs, 'pandas_version', None)) try: self.version = tuple(int(x) for x in version.split('.')) if len(self.version) == 2: self....
[ " compute and set our version " ]
Please provide a description of the function:def set_object_info(self): self.attrs.pandas_type = str(self.pandas_kind) self.attrs.pandas_version = str(_version) self.set_version()
[ " set my pandas type & version " ]
Please provide a description of the function:def infer_axes(self): s = self.storable if s is None: return False self.get_attrs() return True
[ " infer the axes of my storer\n return a boolean indicating if we have a valid storer or not " ]
Please provide a description of the function:def delete(self, where=None, start=None, stop=None, **kwargs): if com._all_none(where, start, stop): self._handle.remove_node(self.group, recursive=True) return None raise TypeError("cannot delete on an abstract storer")
[ "\n support fully deleting the node in its entirety (only) - where\n specification must be None\n " ]
Please provide a description of the function:def validate_read(self, kwargs): kwargs = copy.copy(kwargs) columns = kwargs.pop('columns', None) if columns is not None: raise TypeError("cannot pass a column specification when reading " "a Fixed for...
[ "\n remove table keywords from kwargs and return\n raise if any keywords are passed which are not-None\n " ]
Please provide a description of the function:def set_attrs(self): self.attrs.encoding = self.encoding self.attrs.errors = self.errors
[ " set our object attributes " ]
Please provide a description of the function:def get_attrs(self): self.encoding = _ensure_encoding(getattr(self.attrs, 'encoding', None)) self.errors = _ensure_decoded(getattr(self.attrs, 'errors', 'strict')) for n in self.attributes: setattr(self, n, _ensure_decoded(getattr...
[ " retrieve our attributes " ]
Please provide a description of the function:def read_array(self, key, start=None, stop=None): import tables node = getattr(self.group, key) attrs = node._v_attrs transposed = getattr(attrs, 'transposed', False) if isinstance(node, tables.VLArray): ret = no...
[ " read an array for the specified node (off of group " ]
Please provide a description of the function:def write_array_empty(self, key, value): # ugly hack for length 0 axes arr = np.empty((1,) * value.ndim) self._handle.create_array(self.group, key, arr) getattr(self.group, key)._v_attrs.value_type = str(value.dtype) getattr(...
[ " write a 0-len array " ]
Please provide a description of the function:def validate_read(self, kwargs): kwargs = super().validate_read(kwargs) if 'start' in kwargs or 'stop' in kwargs: raise NotImplementedError("start and/or stop are not supported " "in fixed Sparse read...
[ "\n we don't support start, stop kwds in Sparse\n " ]
Please provide a description of the function:def write(self, obj, **kwargs): super().write(obj, **kwargs) for name, ss in obj.items(): key = 'sparse_series_{name}'.format(name=name) if key not in self.group._v_children: node = self._handle.create_group(se...
[ " write it as a collection of individual sparse series " ]
Please provide a description of the function:def validate(self, other): if other is None: return if other.table_type != self.table_type: raise TypeError( "incompatible table_type with existing " "[{other} - {self}]".format( ...
[ " validate against an existing table " ]
Please provide a description of the function:def validate_metadata(self, existing): self.metadata = [ c.name for c in self.values_axes if c.metadata is not None]
[ " create / validate metadata " ]
Please provide a description of the function:def validate_multiindex(self, obj): levels = [l if l is not None else "level_{0}".format(i) for i, l in enumerate(obj.index.names)] try: return obj.reset_index(), levels except ValueError: raise Value...
[ "validate that we can store the multi-index; reset and return the\n new object\n " ]
Please provide a description of the function:def nrows_expected(self): return np.prod([i.cvalues.shape[0] for i in self.index_axes])
[ " based on our axes, compute the expected nrows " ]
Please provide a description of the function:def data_orientation(self): return tuple(itertools.chain([int(a[0]) for a in self.non_index_axes], [int(a.axis) for a in self.index_axes]))
[ "return a tuple of my permutated axes, non_indexable at the front" ]
Please provide a description of the function:def queryables(self): # compute the values_axes queryables return dict( [(a.cname, a) for a in self.index_axes] + [(self.storage_obj_type._AXIS_NAMES[axis], None) for axis, values in self.non_index_axes] + ...
[ " return a dict of the kinds allowable columns for this object " ]
Please provide a description of the function:def _get_metadata_path(self, key): return "{group}/meta/{key}/meta".format(group=self.group._v_pathname, key=key)
[ " return the metadata pathname for this key " ]
Please provide a description of the function:def write_metadata(self, key, values): values = Series(values) self.parent.put(self._get_metadata_path(key), values, format='table', encoding=self.encoding, errors=self.errors, nan_rep=self.nan_rep)
[ "\n write out a meta data array to the key as a fixed-format Series\n\n Parameters\n ----------\n key : string\n values : ndarray\n\n " ]
Please provide a description of the function:def read_metadata(self, key): if getattr(getattr(self.group, 'meta', None), key, None) is not None: return self.parent.select(self._get_metadata_path(key)) return None
[ " return the meta data array for this key " ]
Please provide a description of the function:def set_attrs(self): self.attrs.table_type = str(self.table_type) self.attrs.index_cols = self.index_cols() self.attrs.values_cols = self.values_cols() self.attrs.non_index_axes = self.non_index_axes self.attrs.data_columns = ...
[ " set our table type & indexables " ]
Please provide a description of the function:def get_attrs(self): self.non_index_axes = getattr( self.attrs, 'non_index_axes', None) or [] self.data_columns = getattr( self.attrs, 'data_columns', None) or [] self.info = getattr( self.attrs, 'info', No...
[ " retrieve our attributes " ]
Please provide a description of the function:def validate_version(self, where=None): if where is not None: if (self.version[0] <= 0 and self.version[1] <= 10 and self.version[2] < 1): ws = incompatibility_doc % '.'.join( [str(x) for x ...
[ " are we trying to operate on an old version? " ]
Please provide a description of the function:def validate_min_itemsize(self, min_itemsize): if min_itemsize is None: return if not isinstance(min_itemsize, dict): return q = self.queryables() for k, v in min_itemsize.items(): # ok, apply gen...
[ "validate the min_itemisze doesn't contain items that are not in the\n axes this needs data_columns to be defined\n " ]
Please provide a description of the function:def indexables(self): if self._indexables is None: self._indexables = [] # index columns self._indexables.extend([ IndexCol(name=name, axis=axis, pos=i) for i, (axis, name) in enumerate(se...
[ " create/cache the indexables if they don't exist " ]
Please provide a description of the function:def create_index(self, columns=None, optlevel=None, kind=None): if not self.infer_axes(): return if columns is False: return # index all indexables and data_columns if columns is None or columns is True: ...
[ "\n Create a pytables index on the specified columns\n note: cannot index Time64Col() or ComplexCol currently;\n PyTables must be >= 3.0\n\n Parameters\n ----------\n columns : False (don't create an index), True (create all columns\n index), None or list_lik...
Please provide a description of the function:def read_axes(self, where, **kwargs): # validate the version self.validate_version(where) # infer the data kind if not self.infer_axes(): return False # create the selection self.selection = Selection(se...
[ "create and return the axes sniffed from the table: return boolean\n for success\n " ]
Please provide a description of the function:def validate_data_columns(self, data_columns, min_itemsize): if not len(self.non_index_axes): return [] axis, axis_labels = self.non_index_axes[0] info = self.info.get(axis, dict()) if info.get('type') == 'MultiIndex' an...
[ "take the input data_columns and min_itemize and create a data\n columns spec\n " ]
Please provide a description of the function:def create_axes(self, axes, obj, validate=True, nan_rep=None, data_columns=None, min_itemsize=None, **kwargs): # set the default axes if needed if axes is None: try: axes = _AXES_MAP[type(obj)] ...
[ " create and return the axes\n leagcy tables create an indexable column, indexable index,\n non-indexable fields\n\n Parameters:\n -----------\n axes: a list of the axes in order to create (names or numbers of\n the axes)\n obj : the object to...
Please provide a description of the function:def process_axes(self, obj, columns=None): # make a copy to avoid side effects if columns is not None: columns = list(columns) # make sure to include levels if we have them if columns is not None and self.is_multi_index:...
[ " process axes filters " ]
Please provide a description of the function:def create_description(self, complib=None, complevel=None, fletcher32=False, expectedrows=None): # provided expected rows if its passed if expectedrows is None: expectedrows = max(self.nrows_expected, 10000) ...
[ " create the description of the table from the axes & values " ]
Please provide a description of the function:def read_coordinates(self, where=None, start=None, stop=None, **kwargs): # validate the version self.validate_version(where) # infer the data kind if not self.infer_axes(): return False # create the selection ...
[ "select coordinates (row numbers) from a table; return the\n coordinates object\n " ]
Please provide a description of the function:def read_column(self, column, where=None, start=None, stop=None): # validate the version self.validate_version() # infer the data kind if not self.infer_axes(): return False if where is not None: rai...
[ "return a single column from the table, generally only indexables\n are interesting\n " ]
Please provide a description of the function:def read(self, where=None, columns=None, **kwargs): if not self.read_axes(where=where, **kwargs): return None raise NotImplementedError("Panel is removed in pandas 0.25.0")
[ "we have n indexable columns, with an arbitrary number of data\n axes\n " ]
Please provide a description of the function:def write_data(self, chunksize, dropna=False): names = self.dtype.names nrows = self.nrows_expected # if dropna==True, then drop ALL nan rows masks = [] if dropna: for a in self.values_axes: # f...
[ " we form the data into a 2-d including indexes,values,mask\n write chunk-by-chunk " ]
Please provide a description of the function:def write_data_chunk(self, rows, indexes, mask, values): # 0 len for v in values: if not np.prod(v.shape): return try: nrows = indexes[0].shape[0] if nrows != len(rows): ro...
[ "\n Parameters\n ----------\n rows : an empty memory space where we are putting the chunk\n indexes : an array of the indexes\n mask : an array of the masks\n values : an array of the values\n " ]
Please provide a description of the function:def write(self, obj, data_columns=None, **kwargs): if not isinstance(obj, DataFrame): name = obj.name or 'values' obj = DataFrame({name: obj}, index=obj.index) obj.columns = [name] return super().write(obj=obj, dat...
[ " we are going to write this as a frame table " ]
Please provide a description of the function:def write(self, obj, **kwargs): name = obj.name or 'values' obj, self.levels = self.validate_multiindex(obj) cols = list(self.levels) cols.append(name) obj.columns = cols return super().write(obj=obj, **kwargs)
[ " we are going to write this as a frame table " ]
Please provide a description of the function:def get_attrs(self): self.non_index_axes = [] self.nan_rep = None self.levels = [] self.index_axes = [a.infer(self) for a in self.indexables if a.is_an_indexable] self.values_axes = [a.infer(self) ...
[ " retrieve our attributes " ]
Please provide a description of the function:def indexables(self): if self._indexables is None: d = self.description # the index columns is just a simple index self._indexables = [GenericIndexCol(name='index', axis=0)] for i, n in enumerate(d._v_names)...
[ " create the indexables from the table description " ]
Please provide a description of the function:def generate(self, where): if where is None: return None q = self.table.queryables() try: return Expr(where, queryables=q, encoding=self.table.encoding) except NameError: # raise a nice message, su...
[ " where can be a : dict,list,tuple,string " ]
Please provide a description of the function:def select(self): if self.condition is not None: return self.table.table.read_where(self.condition.format(), start=self.start, stop=self.stop) e...
[ "\n generate the selection\n " ]
Please provide a description of the function:def select_coords(self): start, stop = self.start, self.stop nrows = self.table.nrows if start is None: start = 0 elif start < 0: start += nrows if self.stop is None: stop = nrows el...
[ "\n generate the selection\n " ]
Please provide a description of the function:def astype(self, dtype, copy=True): return np.array(self, dtype=dtype, copy=copy)
[ "\n Cast to a NumPy array with 'dtype'.\n\n Parameters\n ----------\n dtype : str or dtype\n Typecode or data-type to which the array is cast.\n copy : bool, default True\n Whether to copy the data, even if not necessary. If False,\n a copy is made...
Please provide a description of the function:def argsort(self, ascending=True, kind='quicksort', *args, **kwargs): # Implementor note: You have two places to override the behavior of # argsort. # 1. _values_for_argsort : construct the values passed to np.argsort # 2. argsort : t...
[ "\n Return the indices that would sort this array.\n\n Parameters\n ----------\n ascending : bool, default True\n Whether the indices should result in an ascending\n or descending sort.\n kind : {'quicksort', 'mergesort', 'heapsort'}, optional\n So...
Please provide a description of the function:def fillna(self, value=None, method=None, limit=None): from pandas.api.types import is_array_like from pandas.util._validators import validate_fillna_kwargs from pandas.core.missing import pad_1d, backfill_1d value, method = validate...
[ "\n Fill NA/NaN values using the specified method.\n\n Parameters\n ----------\n value : scalar, array-like\n If a scalar value is passed it is used to fill all missing values.\n Alternatively, an array-like 'value' can be given. It's expected\n that the ...
Please provide a description of the function:def shift( self, periods: int = 1, fill_value: object = None, ) -> ABCExtensionArray: # Note: this implementation assumes that `self.dtype.na_value` can be # stored in an instance of your ExtensionArray with `s...
[ "\n Shift values by desired number.\n\n Newly introduced missing values are filled with\n ``self.dtype.na_value``.\n\n .. versionadded:: 0.24.0\n\n Parameters\n ----------\n periods : int, default 1\n The number of periods to shift. Negative values are all...
Please provide a description of the function:def unique(self): from pandas import unique uniques = unique(self.astype(object)) return self._from_sequence(uniques, dtype=self.dtype)
[ "\n Compute the ExtensionArray of unique values.\n\n Returns\n -------\n uniques : ExtensionArray\n " ]
Please provide a description of the function:def searchsorted(self, value, side="left", sorter=None): # Note: the base tests provided by pandas only test the basics. # We do not test # 1. Values outside the range of the `data_for_sorting` fixture # 2. Values between the values i...
[ "\n Find indices where elements should be inserted to maintain order.\n\n .. versionadded:: 0.24.0\n\n Find the indices into a sorted array `self` (a) such that, if the\n corresponding elements in `value` were inserted before the indices,\n the order of `self` would be preserved.\...
Please provide a description of the function:def _values_for_factorize(self) -> Tuple[np.ndarray, Any]: return self.astype(object), np.nan
[ "\n Return an array and missing value suitable for factorization.\n\n Returns\n -------\n values : ndarray\n\n An array suitable for factorization. This should maintain order\n and be a supported dtype (Float64, Int64, UInt64, String, Object).\n By defaul...
Please provide a description of the function:def factorize( self, na_sentinel: int = -1, ) -> Tuple[np.ndarray, ABCExtensionArray]: # Impelmentor note: There are two ways to override the behavior of # pandas.factorize # 1. _values_for_factorize and _from_fact...
[ "\n Encode the extension array as an enumerated type.\n\n Parameters\n ----------\n na_sentinel : int, default -1\n Value to use in the `labels` array to indicate missing values.\n\n Returns\n -------\n labels : ndarray\n An integer NumPy array ...
Please provide a description of the function:def take( self, indices: Sequence[int], allow_fill: bool = False, fill_value: Any = None ) -> ABCExtensionArray: # Implementer note: The `fill_value` parameter should be a user-facing # value, an in...
[ "\n Take elements from an array.\n\n Parameters\n ----------\n indices : sequence of integers\n Indices to be taken.\n allow_fill : bool, default False\n How to handle negative values in `indices`.\n\n * False: negative values in `indices` indicate...
Please provide a description of the function:def _formatter( self, boxed: bool = False, ) -> Callable[[Any], Optional[str]]: if boxed: return str return repr
[ "Formatting function for scalar values.\n\n This is used in the default '__repr__'. The returned formatting\n function receives instances of your scalar type.\n\n Parameters\n ----------\n boxed: bool, default False\n An indicated for whether or not your array is being ...
Please provide a description of the function:def _reduce(self, name, skipna=True, **kwargs): raise TypeError("cannot perform {name} with type {dtype}".format( name=name, dtype=self.dtype))
[ "\n Return a scalar result of performing the reduction operation.\n\n Parameters\n ----------\n name : str\n Name of the function, supported values are:\n { any, all, min, max, sum, mean, median, prod,\n std, var, sem, kurt, skew }.\n skipna : bool...
Please provide a description of the function:def _create_method(cls, op, coerce_to_dtype=True): def _binop(self, other): def convert_values(param): if isinstance(param, ExtensionArray) or is_list_like(param): ovalues = param else: # Assu...
[ "\n A class method that returns a method that will correspond to an\n operator for an ExtensionArray subclass, by dispatching to the\n relevant operator defined on the individual elements of the\n ExtensionArray.\n\n Parameters\n ----------\n op : function\n ...
Please provide a description of the function:def ea_passthrough(array_method): def method(self, *args, **kwargs): return array_method(self._data, *args, **kwargs) method.__name__ = array_method.__name__ method.__doc__ = array_method.__doc__ return method
[ "\n Make an alias for a method of the underlying ExtensionArray.\n\n Parameters\n ----------\n array_method : method on an Array class\n\n Returns\n -------\n method\n " ]
Please provide a description of the function:def _create_comparison_method(cls, op): def wrapper(self, other): if isinstance(other, ABCSeries): # the arrays defer to Series for comparison ops but the indexes # don't, so we have to unwrap here. ...
[ "\n Create a comparison method that dispatches to ``cls.values``.\n " ]
Please provide a description of the function:def equals(self, other): if self.is_(other): return True if not isinstance(other, ABCIndexClass): return False elif not isinstance(other, type(self)): try: other = type(self)(other) ...
[ "\n Determines if two Index objects contain the same elements.\n " ]
Please provide a description of the function:def _join_i8_wrapper(joinf, dtype, with_indexers=True): from pandas.core.arrays.datetimelike import DatetimeLikeArrayMixin @staticmethod def wrapper(left, right): if isinstance(left, (np.ndarray, ABCIndex, ABCSeries, ...
[ "\n Create the join wrapper methods.\n " ]
Please provide a description of the function:def sort_values(self, return_indexer=False, ascending=True): if return_indexer: _as = self.argsort() if not ascending: _as = _as[::-1] sorted_index = self.take(_as) return sorted_index, _as ...
[ "\n Return sorted copy of Index.\n " ]
Please provide a description of the function:def min(self, axis=None, skipna=True, *args, **kwargs): nv.validate_min(args, kwargs) nv.validate_minmax_axis(axis) if not len(self): return self._na_value i8 = self.asi8 try: # quick check ...
[ "\n Return the minimum value of the Index or minimum along\n an axis.\n\n See Also\n --------\n numpy.ndarray.min\n Series.min : Return the minimum value in a Series.\n " ]
Please provide a description of the function:def argmin(self, axis=None, skipna=True, *args, **kwargs): nv.validate_argmin(args, kwargs) nv.validate_minmax_axis(axis) i8 = self.asi8 if self.hasnans: mask = self._isnan if mask.all() or not skipna: ...
[ "\n Returns the indices of the minimum values along an axis.\n\n See `numpy.ndarray.argmin` for more information on the\n `axis` parameter.\n\n See Also\n --------\n numpy.ndarray.argmin\n " ]
Please provide a description of the function:def max(self, axis=None, skipna=True, *args, **kwargs): nv.validate_max(args, kwargs) nv.validate_minmax_axis(axis) if not len(self): return self._na_value i8 = self.asi8 try: # quick check ...
[ "\n Return the maximum value of the Index or maximum along\n an axis.\n\n See Also\n --------\n numpy.ndarray.max\n Series.max : Return the maximum value in a Series.\n " ]
Please provide a description of the function:def argmax(self, axis=None, skipna=True, *args, **kwargs): nv.validate_argmax(args, kwargs) nv.validate_minmax_axis(axis) i8 = self.asi8 if self.hasnans: mask = self._isnan if mask.all() or not skipna: ...
[ "\n Returns the indices of the maximum values along an axis.\n\n See `numpy.ndarray.argmax` for more information on the\n `axis` parameter.\n\n See Also\n --------\n numpy.ndarray.argmax\n " ]
Please provide a description of the function:def _format_attrs(self): attrs = super()._format_attrs() for attrib in self._attributes: if attrib == 'freq': freq = self.freqstr if freq is not None: freq = "'%s'" % freq ...
[ "\n Return a list of tuples of the (attr,formatted_value).\n " ]
Please provide a description of the function:def _convert_scalar_indexer(self, key, kind=None): assert kind in ['ix', 'loc', 'getitem', 'iloc', None] # we don't allow integer/float indexing for loc # we don't allow float indexing for ix/getitem if is_scalar(key): i...
[ "\n We don't allow integer or float indexing on datetime-like when using\n loc.\n\n Parameters\n ----------\n key : label of the slice bound\n kind : {'ix', 'loc', 'getitem', 'iloc'} or None\n " ]
Please provide a description of the function:def _add_datetimelike_methods(cls): def __add__(self, other): # dispatch to ExtensionArray implementation result = self._data.__add__(maybe_unwrap_index(other)) return wrap_arithmetic_op(self, other, result) cls....
[ "\n Add in the datetimelike methods (as we may have to override the\n superclass).\n " ]
Please provide a description of the function:def isin(self, values): if not isinstance(values, type(self)): try: values = type(self)(values) except ValueError: return self.astype(object).isin(values) return algorithms.isin(self.asi8, valu...
[ "\n Compute boolean array of whether each index value is found in the\n passed set of values.\n\n Parameters\n ----------\n values : set or sequence of values\n\n Returns\n -------\n is_contained : ndarray (boolean dtype)\n " ]
Please provide a description of the function:def _summary(self, name=None): formatter = self._formatter_func if len(self) > 0: index_summary = ', %s to %s' % (formatter(self[0]), formatter(self[-1])) else: index_summary...
[ "\n Return a summarized representation.\n\n Parameters\n ----------\n name : str\n name to use in the summary representation\n\n Returns\n -------\n String with a summarized representation of the index\n " ]
Please provide a description of the function:def _concat_same_dtype(self, to_concat, name): attribs = self._get_attributes_dict() attribs['name'] = name # do not pass tz to set because tzlocal cannot be hashed if len({str(x.dtype) for x in to_concat}) != 1: raise Val...
[ "\n Concatenate to_concat which has the same class.\n " ]
Please provide a description of the function:def shift(self, periods, freq=None): result = self._data._time_shift(periods, freq=freq) return type(self)(result, name=self.name)
[ "\n Shift index by desired number of time frequency increments.\n\n This method is for shifting the values of datetime-like indexes\n by a specified time increment a given number of times.\n\n Parameters\n ----------\n periods : int\n Number of periods (or increm...
Please provide a description of the function:def _single_replace(self, to_replace, method, inplace, limit): if self.ndim != 1: raise TypeError('cannot replace {0} with method {1} on a {2}' .format(to_replace, method, type(self).__name__)) orig_dtype = self.dtype result ...
[ "\n Replaces values in a Series using the fill method specified when no\n replacement value is given in the replace method\n " ]
Please provide a description of the function:def _doc_parms(cls): axis_descr = "{%s}" % ', '.join("{0} ({1})".format(a, i) for i, a in enumerate(cls._AXIS_ORDERS)) name = (cls._constructor_sliced.__name__ if cls._AXIS_LEN > 1 else 'scalar') name2 = cls.__...
[ "Return a tuple of the doc parms." ]
Please provide a description of the function:def _init_mgr(self, mgr, axes=None, dtype=None, copy=False): for a, axe in axes.items(): if axe is not None: mgr = mgr.reindex_axis(axe, axis=self._get_block_manager_axis(a), ...
[ " passed a manager and a axes dict " ]
Please provide a description of the function:def _validate_dtype(self, dtype): if dtype is not None: dtype = pandas_dtype(dtype) # a compound dtype if dtype.kind == 'V': raise NotImplementedError("compound dtypes are not implemented" ...
[ " validate the passed dtype " ]
Please provide a description of the function:def _setup_axes(cls, axes, info_axis=None, stat_axis=None, aliases=None, slicers=None, axes_are_reversed=False, build_axes=True, ns=None, docs=None): cls._AXIS_ORDERS = axes cls._AXIS_NUMBERS = {a: i for i, a ...
[ "Provide axes setup for the major PandasObjects.\n\n Parameters\n ----------\n axes : the names of the axes in order (lowest to highest)\n info_axis_num : the axis of the selector dimension (int)\n stat_axis_num : the number of axis for the default stats (int)\n aliases : o...
Please provide a description of the function:def _construct_axes_dict(self, axes=None, **kwargs): d = {a: self._get_axis(a) for a in (axes or self._AXIS_ORDERS)} d.update(kwargs) return d
[ "Return an axes dictionary for myself." ]
Please provide a description of the function:def _construct_axes_dict_from(self, axes, **kwargs): d = {a: ax for a, ax in zip(self._AXIS_ORDERS, axes)} d.update(kwargs) return d
[ "Return an axes dictionary for the passed axes." ]
Please provide a description of the function:def _construct_axes_dict_for_slice(self, axes=None, **kwargs): d = {self._AXIS_SLICEMAP[a]: self._get_axis(a) for a in (axes or self._AXIS_ORDERS)} d.update(kwargs) return d
[ "Return an axes dictionary for myself." ]
Please provide a description of the function:def _construct_axes_from_arguments( self, args, kwargs, require_all=False, sentinel=None): # construct the args args = list(args) for a in self._AXIS_ORDERS: # if we have an alias for this axis alias = se...
[ "Construct and returns axes if supplied in args/kwargs.\n\n If require_all, raise if all axis arguments are not supplied\n return a tuple of (axes, kwargs).\n\n sentinel specifies the default parameter when an axis is not\n supplied; useful to distinguish when a user explicitly passes No...
Please provide a description of the function:def _get_block_manager_axis(cls, axis): axis = cls._get_axis_number(axis) if cls._AXIS_REVERSED: m = cls._AXIS_LEN - 1 return m - axis return axis
[ "Map the axis to the block_manager axis." ]
Please provide a description of the function:def _get_space_character_free_column_resolvers(self): from pandas.core.computation.common import _remove_spaces_column_name return {_remove_spaces_column_name(k): v for k, v in self.iteritems()}
[ "Return the space character free column resolvers of a dataframe.\n\n Column names with spaces are 'cleaned up' so that they can be referred\n to by backtick quoting.\n Used in :meth:`DataFrame.eval`.\n " ]
Please provide a description of the function:def shape(self): return tuple(len(self._get_axis(a)) for a in self._AXIS_ORDERS)
[ "\n Return a tuple of axis dimensions\n " ]
Please provide a description of the function:def transpose(self, *args, **kwargs): # construct the args axes, kwargs = self._construct_axes_from_arguments(args, kwargs, require_all=True) axes_names = tuple(self._get_axis_name(a...
[ "\n Permute the dimensions of the %(klass)s\n\n Parameters\n ----------\n args : %(args_transpose)s\n copy : boolean, default False\n Make a copy of the underlying data. Mixed-dtype data will\n always result in a copy\n **kwargs\n Additional...
Please provide a description of the function:def swapaxes(self, axis1, axis2, copy=True): i = self._get_axis_number(axis1) j = self._get_axis_number(axis2) if i == j: if copy: return self.copy() return self mapping = {i: j, j: i} ...
[ "\n Interchange axes and swap values axes appropriately.\n\n Returns\n -------\n y : same as input\n " ]
Please provide a description of the function:def droplevel(self, level, axis=0): labels = self._get_axis(axis) new_labels = labels.droplevel(level) result = self.set_axis(new_labels, axis=axis, inplace=False) return result
[ "\n Return DataFrame with requested index / column level(s) removed.\n\n .. versionadded:: 0.24.0\n\n Parameters\n ----------\n level : int, str, or list-like\n If a string is given, must be the name of a level\n If list-like, elements must be names or positi...
Please provide a description of the function:def squeeze(self, axis=None): axis = (self._AXIS_NAMES if axis is None else (self._get_axis_number(axis),)) try: return self.iloc[ tuple(0 if i in axis and len(a) == 1 else slice(None) ...
[ "\n Squeeze 1 dimensional axis objects into scalars.\n\n Series or DataFrames with a single element are squeezed to a scalar.\n DataFrames with a single column or a single row are squeezed to a\n Series. Otherwise the object is unchanged.\n\n This method is most useful when you do...
Please provide a description of the function:def swaplevel(self, i=-2, j=-1, axis=0): axis = self._get_axis_number(axis) result = self.copy() labels = result._data.axes[axis] result._data.set_axis(axis, labels.swaplevel(i, j)) return result
[ "\n Swap levels i and j in a MultiIndex on a particular axis\n\n Parameters\n ----------\n i, j : int, str (can be mixed)\n Level of index to be swapped. Can pass level name as string.\n\n Returns\n -------\n swapped : same type as caller (new object)\n\n ...
Please provide a description of the function:def rename(self, *args, **kwargs): axes, kwargs = self._construct_axes_from_arguments(args, kwargs) copy = kwargs.pop('copy', True) inplace = kwargs.pop('inplace', False) level = kwargs.pop('level', None) axis = kwargs.pop('ax...
[ "\n Alter axes input function or functions. Function / dict values must be\n unique (1-to-1). Labels not contained in a dict / Series will be left\n as-is. Extra labels listed don't throw an error. Alternatively, change\n ``Series.name`` with a scalar value (Series only).\n\n Para...
Please provide a description of the function:def rename_axis(self, mapper=sentinel, **kwargs): axes, kwargs = self._construct_axes_from_arguments( (), kwargs, sentinel=sentinel) copy = kwargs.pop('copy', True) inplace = kwargs.pop('inplace', False) axis = kwargs.pop(...
[ "\n Set the name of the axis for the index or columns.\n\n Parameters\n ----------\n mapper : scalar, list-like, optional\n Value to set the axis name attribute.\n index, columns : scalar, list-like, dict-like or function, optional\n A scalar, list-like, dict...
Please provide a description of the function:def _set_axis_name(self, name, axis=0, inplace=False): axis = self._get_axis_number(axis) idx = self._get_axis(axis).set_names(name) inplace = validate_bool_kwarg(inplace, 'inplace') renamed = self if inplace else self.copy() ...
[ "\n Set the name(s) of the axis.\n\n Parameters\n ----------\n name : str or list of str\n Name(s) to set.\n axis : {0 or 'index', 1 or 'columns'}, default 0\n The axis to set the label. The value 0 or 'index' specifies index,\n and the value 1 or ...
Please provide a description of the function:def equals(self, other): if not isinstance(other, self._constructor): return False return self._data.equals(other._data)
[ "\n Test whether two objects contain the same elements.\n\n This function allows two Series or DataFrames to be compared against\n each other to see if they have the same shape and elements. NaNs in\n the same location are considered equal. The column headers do not\n need to have...
Please provide a description of the function:def bool(self): v = self.squeeze() if isinstance(v, (bool, np.bool_)): return bool(v) elif is_scalar(v): raise ValueError("bool cannot act on a non-boolean single element " "{0}".format(sel...
[ "\n Return the bool of a single element PandasObject.\n\n This must be a boolean scalar value, either True or False. Raise a\n ValueError if the PandasObject does not have exactly 1 element, or that\n element is not boolean\n " ]
Please provide a description of the function:def _is_level_reference(self, key, axis=0): axis = self._get_axis_number(axis) if self.ndim > 2: raise NotImplementedError( "_is_level_reference is not implemented for {type}" .format(type=type(self))) ...
[ "\n Test whether a key is a level reference for a given axis.\n\n To be considered a level reference, `key` must be a string that:\n - (axis=0): Matches the name of an index level and does NOT match\n a column label.\n - (axis=1): Matches the name of a column level and doe...
Please provide a description of the function:def _is_label_reference(self, key, axis=0): if self.ndim > 2: raise NotImplementedError( "_is_label_reference is not implemented for {type}" .format(type=type(self))) axis = self._get_axis_number(axis) ...
[ "\n Test whether a key is a label reference for a given axis.\n\n To be considered a label reference, `key` must be a string that:\n - (axis=0): Matches a column label\n - (axis=1): Matches an index label\n\n Parameters\n ----------\n key: str\n Potent...