- class craftutils.wrap.dragons.Table.Column(astropy.table.column.BaseColumn)
Define a data column for use in a Table object.
Parameters¶
- datalist, ndarray, or None
Column data values
- namestr
Column name and key for reference within Table
- dtype~numpy.dtype-like
Data type for column
- shapetuple or ()
Dimensions of a single row element in the column data
- lengthint or 0
Number of row elements in column data
- descriptionstr or None
Full description of column
- unitstr or None
Physical unit
- formatstr, None, or callable
Format string for outputting column values. This can be an “old-style” (
format % value) or “new-style” (str.format) format specification string or a function or any callable object that accepts a single value and returns a string.- metadict-like or None
Meta-data associated with the column
Examples¶
A Column can be created in two different ways:
Provide a
datavalue but notshapeorlength(which are inferred from the data).Examples:
col = Column(data=[1, 2], name='name') # shape=(2,) col = Column(data=[[1, 2], [3, 4]], name='name') # shape=(2, 2) col = Column(data=[1, 2], name='name', dtype=float) col = Column(data=np.array([1, 2]), name='name') col = Column(data=['hello', 'world'], name='name')The
dtypeargument can be any value which is an acceptable fixed-size data-type initializer for the numpy.dtype() method. See https://numpy.org/doc/stable/reference/arrays.dtypes.html. Examples include:Python non-string type (float, int, bool)
Numpy non-string type (e.g. np.float32, np.int64, np.bool_)
Numpy.dtype array-protocol type strings (e.g. ‘i4’, ‘f8’, ‘S15’)
If no
dtypevalue is provide then the type is inferred usingnp.array(data).Provide
lengthand optionallyshape, but notdataExamples:
col = Column(name='name', length=5) col = Column(name='name', dtype=int, length=10, shape=(3,4))The default
dtypeisnp.float64. Theshapeargument is the array shape of a single cell in the column.
To access the
Columndata as a raw numpy.ndarray object, you can use one of thedataorvalueattributes (which are equivalent):col.data col.valuePublic members¶
-
static Column(cls, data=
None, name=None, dtype=None, shape=(), ...) Create and return a new object. See help(type) for accurate signature.
- __setattr__(item, value)
Implement setattr(self, name, value).
- __repr__()
Return repr(self).
- __str__()
Return str(self).
- __setitem__(index, value)
Set self[key] to value.
- __eq__(other)
Return self==value.
- __ne__(other)
Return self!=value.
- __gt__(other)
Return self>value.
- __lt__(other)
Return self<value.
- __ge__(other)
Return self>=value.
- __le__(other)
Return self<=value.
-
insert(obj, values, axis=
0) Insert values before the given indices in the column and return a new ~astropy.table.Column object.
-
copy(order=
'C', data=None, copy_data=True) Return a copy of the current instance.
-
more(max_lines=
None, show_name=True, show_unit=False) Interactively browse column with a paging interface.
-
pprint(max_lines=
None, show_name=True, show_unit=False, ...) Print a formatted string representation of column values.
-
pformat(max_lines=
None, show_name=True, show_unit=False, ...) Return a list of formatted string representation of column values.
-
convert_unit_to(new_unit, equivalencies=
[]) Converts the values of the column in-place from the current unit to the given unit.
-
to(unit, equivalencies=
[], **kwargs) Converts this table column to a ~astropy.units.Quantity object with the requested units.
- info
Container for meta information like name, description, format.
- __reduce__()
Return a 3-tuple for pickling a Column. Use the super-class functionality but then add in a 5-tuple of Column-specific values that get used in __setstate__.
- __array_finalize__(obj, /)
Present so subclasses can call super. Does nothing.
-
__array_wrap__(out_arr, context=
None) __array_wrap__ is called at the end of every ufunc.
- iter_str_vals()
Return an iterator that yields the string-formatted values of this column.
- attrs_equal(col)
Compare the column attributes of
colto this object.
-
searchsorted(v, side=
'left', sorter=None) Find indices where elements of v should be inserted in a to maintain order.
- group_by(keys)
Group this column by the specified
keys
- tolist()
Return the array as an
a.ndim-levels deep nested list of Python scalars.
- __getitem__(key, /)
Return self[key].
- __iter__()
Implement iter(self).
- __add__(value, /)
Return self+value.
- __radd__(value, /)
Return value+self.
- __sub__(value, /)
Return self-value.
- __rsub__(value, /)
Return value-self.
- __mul__(value, /)
Return self*value.
- __rmul__(value, /)
Return value*self.
- __mod__(value, /)
Return self%value.
- __rmod__(value, /)
Return value%self.
- __divmod__(value, /)
Return divmod(self, value).
- __rdivmod__(value, /)
Return divmod(value, self).
-
__pow__(value, mod=
None, /) Return pow(self, value, mod).
-
__rpow__(value, mod=
None, /) Return pow(value, self, mod).
- __neg__()
-self
- __pos__()
+self
- __abs__()
abs(self)
- __bool__()
self != 0
- __invert__()
~self
- __lshift__(value, /)
Return self<<value.
- __rlshift__(value, /)
Return value<<self.
- __rshift__(value, /)
Return self>>value.
- __rrshift__(value, /)
Return value>>self.
- __and__(value, /)
Return self&value.
- __rand__(value, /)
Return value&self.
- __xor__(value, /)
Return self^value.
- __rxor__(value, /)
Return value^self.
- __or__(value, /)
Return self|value.
- __ror__(value, /)
Return value|self.
- __int__()
int(self)
- __float__()
float(self)
- __iadd__(value, /)
Return self+=value.
- __isub__(value, /)
Return self-=value.
- __imul__(value, /)
Return self*=value.
- __imod__(value, /)
Return self%=value.
- __ipow__(value, /)
Return self**=value.
- __ilshift__(value, /)
Return self<<=value.
- __irshift__(value, /)
Return self>>=value.
- __iand__(value, /)
Return self&=value.
- __ixor__(value, /)
Return self^=value.
- __ior__(value, /)
Return self|=value.
- __floordiv__(value, /)
Return self//value.
- __rfloordiv__(value, /)
Return value//self.
- __truediv__(value, /)
Return self/value.
- __rtruediv__(value, /)
Return value/self.
- __ifloordiv__(value, /)
Return self//=value.
- __itruediv__(value, /)
Return self/=value.
- __index__()
Return self converted to an integer, if self is suitable for use as an index into a list.
- __matmul__(value, /)
Return self@value.
- __rmatmul__(value, /)
Return value@self.
- __imatmul__(value, /)
Return self@=value.
- __len__()
Return len(self).
- __delitem__(key, /)
Delete self[key].
- __contains__(key, /)
Return key in self.
- __array__(...) reference if type unchanged, copy otherwise.
Returns either a new reference to self if dtype is not given or a new array of provided data type if dtype is different from the current dtype of the array.
- __array_prepare__(array, [context, ]/)
Returns a view of array with the same type as self.
- __sizeof__()
Size of object in memory, in bytes.
- __copy__()
Used if
copy.copy()is called on an array. Returns a copy of the array.
- __deepcopy__(memo, /) Deep copy of array.
Used if
copy.deepcopy()is called on an array.
- __reduce_ex__()
Helper for pickle.
- dumps()
Returns the pickle of the array as a string. pickle.loads will convert the string back to an array.
- dump(file)
Dump a pickle of the array to the specified file. The array can be read back with pickle.load or numpy.load.
- __format__()
Default object formatter.
- Column[item, /]
Return a parametrized wrapper around the ~numpy.ndarray type.
-
all(axis=
None, out=None, keepdims=False, *, where=True) Returns True if all elements evaluate to True.
-
any(axis=
None, out=None, keepdims=False, *, where=True) Returns True if any of the elements of a evaluate to True.
-
argmax(axis=
None, out=None, *, keepdims=False) Return indices of the maximum values along the given axis.
-
argmin(axis=
None, out=None, *, keepdims=False) Return indices of the minimum values along the given axis.
-
argpartition(kth, axis=
- 1, kind='introselect', order=None) Returns the indices that would partition this array.
-
argsort(axis=
- 1, kind=None, order=None) Returns the indices that would sort this array.
-
astype(dtype, order=
'K', casting='unsafe', subok=True, copy=True) Copy of the array, cast to a specified type.
-
byteswap(inplace=
False) Swap the bytes of the array elements
-
choose(choices, out=
None, mode='raise') Use an index array to construct a new array from a set of choices.
-
clip(min=
None, max=None, out=None, **kwargs) Return an array whose values are limited to
[min, max]. One of max or min must be given.
-
compress(condition, axis=
None, out=None) Return selected slices of this array along given axis.
- conj()
Complex-conjugate all elements.
- conjugate()
Return the complex conjugate, element-wise.
-
cumprod(axis=
None, dtype=None, out=None) Return the cumulative product of the elements along the given axis.
-
cumsum(axis=
None, dtype=None, out=None) Return the cumulative sum of the elements along the given axis.
-
diagonal(offset=
0, axis1=0, axis2=1) Return specified diagonals. In NumPy 1.9 the returned array is a read-only view instead of a copy as in previous NumPy versions. In a future version the read-only restriction will be removed.
- dot()
- fill(value)
Fill the array with a scalar value.
-
flatten(order=
'C') Return a copy of the array collapsed into one dimension.
-
getfield(dtype, offset=
0) Returns a field of the given array as a certain type.
- item(*args)
Copy an element of an array to a standard Python scalar and return it.
- itemset(*args)
Insert scalar into an array (scalar is cast to array’s dtype, if possible)
- max(axis=None, out=None, keepdims=False, initial=<no value>, ...)
Return the maximum along a given axis.
-
mean(axis=
None, dtype=None, out=None, keepdims=False, *, where=True) Returns the average of the array elements along given axis.
- min(axis=None, out=None, keepdims=False, initial=<no value>, ...)
Return the minimum along a given axis.
-
newbyteorder(new_order=
'S', /) Return the array with the same data viewed with a different byte order.
- nonzero()
Return the indices of the elements that are non-zero.
-
partition(kth, axis=
- 1, kind='introselect', order=None) Rearranges the elements in the array in such a way that the value of the element in kth position is in the position it would be in a sorted array. All elements smaller than the kth element are moved before this element and all equal or greater are moved behind it. The ordering of the elements in the two partitions is undefined.
-
prod(axis=
None, dtype=None, out=None, keepdims=False, ...) Return the product of the array elements over the given axis
-
ptp(axis=
None, out=None, keepdims=False) Peak to peak (maximum - minimum) value along a given axis.
-
put(indices, values, mode=
'raise') Set
a.flat[n] = values[n]for all n in indices.
- ravel([order])
Return a flattened array.
-
repeat(repeats, axis=
None) Repeat elements of an array.
-
reshape(shape, order=
'C') Returns an array containing the same data with a new shape.
-
resize(new_shape, refcheck=
True) Change shape and size of array in-place.
-
round(decimals=
0, out=None) Return a with each element rounded to the given number of decimals.
-
setfield(val, dtype, offset=
0) Put a value into a specified place in a field defined by a data-type.
-
setflags(write=
None, align=None, uic=None) Set array flags WRITEABLE, ALIGNED, WRITEBACKIFCOPY, respectively.
-
sort(axis=
- 1, kind=None, order=None) Sort an array in-place. Refer to numpy.sort for full documentation.
-
squeeze(axis=
None) Remove axes of length one from a.
-
std(axis=
None, dtype=None, out=None, ddof=0, keepdims=False, *, ...) Returns the standard deviation of the array elements along given axis.
-
sum(axis=
None, dtype=None, out=None, keepdims=False, initial=0, ...) Return the sum of the array elements over the given axis.
- swapaxes(axis1, axis2)
Return a view of the array with axis1 and axis2 interchanged.
-
take(indices, axis=
None, out=None, mode='raise') Return an array formed from the elements of a at the given indices.
-
tobytes(order=
'C') Construct Python bytes containing the raw data bytes in the array.
-
tofile(fid, sep=
'', format='%s') Write array to a file as text or binary (default).
-
tostring(order=
'C') A compatibility alias for tobytes, with exactly the same behavior.
-
trace(offset=
0, axis1=0, axis2=1, dtype=None, out=None) Return the sum along diagonals of the array.
- transpose(*axes)
Returns a view of the array with axes transposed.
-
var(axis=
None, dtype=None, out=None, ddof=0, keepdims=False, *, ...) Returns the variance of the array elements, along given axis.
- view([dtype][, type])
New view of array with the same data.
-
__dlpack__(*, stream=
None) DLPack Protocol: Part of the Array API.
- __dlpack_device__()
DLPack Protocol: Part of the Array API.
- ndim
Number of array dimensions.
- flags
Information about the memory layout of the array.
- shape
Tuple of array dimensions.
- strides
Tuple of bytes to step in each dimension when traversing an array.
- itemsize
Length of one array element in bytes.
- size
Number of elements in the array.
- nbytes
Total bytes consumed by the elements of the array.
- base
Base object if memory is from some other object.
- dtype
Data-type of the array’s elements.
- real
The real part of the array.
- imag
The imaginary part of the array.
- flat
A 1-D iterator over the array.
- ctypes
An object to simplify the interaction of the array with the ctypes module.
- T
View of the transposed array.
- __array_interface__
Array protocol: Python side.
- __array_struct__
Array protocol: C-struct side.
- __array_priority__
Array priority.
Properties¶
- property name
The name of this column.
- property unit
The unit associated with this column. May be a string or a astropy.units.UnitBase instance.
- property quantity
A view of this table column as a ~astropy.units.Quantity object with units given by the Column’s unit parameter.
- property data
Python buffer object pointing to the start of the array’s data.
- property value
An alias for the existing
dataattribute.
- property parent_table
- property format
Format string for displaying values in this column.
- property descr
Array-interface compliant full description of the column.
- property groups