Columns and rows¶
agate.MappedSequence |
A generic container for immutable data that can be accessed either by numeric index or by key. |
agate.Column |
Proxy access to column data. |
agate.Row |
A row of data. |
-
class
agate.
MappedSequence
(values, keys=None)¶ Bases:
_abcoll.Sequence
A generic container for immutable data that can be accessed either by numeric index or by key. This is similar to an
collections.OrderedDict
except that the keys are optional and iteration over it returns the values instead of keys.This is the base class for both
Column
andRow
.Parameters: - values – A sequence of values.
- keys – A sequence of keys.
-
dict
()¶ Retrieve the contents of this sequence as an
collections.OrderedDict
.
-
get
(key, default=None)¶ Equivalent to
collections.OrderedDict.get()
.
-
items
()¶ Equivalent to
collections.OrderedDict.items()
.
-
keys
()¶ Equivalent to
collections.OrderedDict.keys()
.
-
values
()¶ Equivalent to
collections.OrderedDict.values()
.
-
class
agate.
Column
(index, name, data_type, rows, row_names=None)¶ Bases:
agate.mapped_sequence.MappedSequence
Proxy access to column data. Instances of
Column
should not be constructed directly. They are created byTable
instances and are unique to them.Columns are implemented as subclass of
MappedSequence
. They deviate from the underlying implementation in that loading of their data is deferred until it is needed.Parameters: - name – The name of this column.
- data_type – An instance of
DataType
. - rows – A
MappedSequence
that contains theRow
instances containing the data for this column. - row_names – An optional list of row names (keys) for this column.
-
data_type
¶ This column’s data type.
-
index
¶ This column’s index.
-
name
¶ This column’s name.
-
values
()¶ Get the values in this column, as a tuple.
-
values_distinct
()¶ Get the distinct values in this column, as a tuple.
-
values_sorted
()¶ Get the values in this column sorted.
-
values_without_nulls
()¶ Get the values in this column with any null values removed.
-
values_without_nulls_sorted
()¶ Get the values in this column with any null values removed and sorted.
-
class
agate.
Row
(values, keys=None)¶ Bases:
agate.mapped_sequence.MappedSequence
A row of data. Values within a row can be accessed by column name or column index. Row are immutable and may be shared between
Table
instances.Currently row instances are a no-op subclass of
MappedSequence
. They are being maintained in this fashion in order to support future features.