PyvtTbl Overview¶
Description¶
PyvtTbl
objects are containers for holding pivoted data.
They are instantiated through DataFrame.pivot.
Public Methods¶
Additional methods inherented from np.ma.MaskedArray that are not explicitely listed here may also be available. Keep in mind methods not listed here may not been have extensively tested.
See also
- static PyvtTbl.__new__(cls, data, val, conditions, rnames, cnames, aggregate, **kwds)¶
creates a new PyvtTbl from scratch
- args:
data: np.ma.array object holding pivoted data
val: string label for the data in the table
conditions: Dictset representing the factors and levels in the table
rnames: list of row labels
cnames: list of column labels
aggregate: string describing the aggregate function applied to the data
- kwds:
calc tots: bool specifying whether totals were calculated
row_tots: row totals in a MaskedArray
col_tots: column totals in a MaskedArray
grand_tot: float holding grand total
attach_rlabels: bool specifying whether row labels are part of the table
subclassing Numpy objects are a little different from subclassing other objects.
- PyvtTbl.transpose()¶
returns a transposed PyvtTbl object
- PyvtTbl.__getitem__(indx)¶
Return the item described by indx, as a PyvtTbl
- args:
- indx: index to array
can be int, tuple(int, int), tuple(slice, int), tuple(int, slice) or tuple(slice, slice)
x[int] <==> x[int,:]
- returns:
PyvtTbl that is at least 2-dimensional (unless indx is tuple(int, int))
x.__getitem__(indx) <==> x[indx]
- PyvtTbl.astype(dtype)¶
Convert the input to an array.
- args:
- a: array_like Input data, in any form that can be converted to an array. This
includes lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays.
- kwds:
dtype: data-type. By default, the data-type is inferred from the input data.
- order: {‘C’, ‘F’} Whether to use row-major (‘C’) or column-major (‘F’ for FORTRAN)
memory representation. Defaults to ‘C’.
- returns:
- out: ndarray
Array interpretation of a. No copy is performed if the input is already an ndarray. If a is a subclass of ndarray, a base class ndarray is returned.
- PyvtTbl.flatten()¶
returns a the PyvtTbl flattened as a MaskedArray
- PyvtTbl.__iter__()¶
Implement iter(self).
- PyvtTbl.ndenumerate()¶
Multidimensional index iterator.
- returns:
returns an iterator yielding pairs of array coordinates and values.
- pyvttbl.PyvtTbl.flat¶
Flat iterator object to iterate over PyvtTbl.
x.flat
for any PyvtTbl- PyvtTbl.__repr__()¶
returns a machine friendly string representation of the object
- PyvtTbl.__str__()¶
returns a human friendly string representation of the table
- PyvtTbl.to_dataframe()¶
returns a DataFrame excluding row and column totals
- PyvtTbl.__add__()¶
Add self to other, and return a new PyvtTbl.
- PyvtTbl.__radd__()¶
Add other to self, and return a new PyvtTbl.
- PyvtTbl.__sub__()¶
Subtract other from self, and return a new PyvtTbl.
- PyvtTbl.__rsub__()¶
Subtract self from other, and return a new PyvtTbl.
- PyvtTbl.__pow__()¶
Raise self to the power other, masking the potential NaNs/Infs
- PyvtTbl.__mul__()¶
Multiply self by other, and return a new PyvtTbl.
- PyvtTbl.__rmul__()¶
Multiply other by self, and return a new PyvtTbl.
- PyvtTbl.__div__()¶
Divide other into self, and return a new PyvtTbl.
- PyvtTbl.__truediv__()¶
Divide other into self, and return a new PyvtTbl.
- PyvtTbl.__rtruediv__()¶
Divide self into other, and return a new PyvtTbl.
- PyvtTbl.__floordiv__()¶
Divide other into self, and return a new PyvtTbl.
- PyvtTbl.__rfloordiv__()¶
Divide self into other, and return a new PyvtTbl.
Private Methods¶
helper methods for PyvtTbl
- PyvtTbl._get_rows()¶
returns a list of tuples containing row labels and conditions
- PyvtTbl._get_cols()¶
returns a list of tuples containing column labels and conditions