google.cloud.bigquery.table.Row¶
-
class
google.cloud.bigquery.table.
Row
(values, field_to_index)[source]¶ A BigQuery row.
Values can be accessed by position (index), by key like a dict, or as properties.
- Parameters
-
__init__
(values, field_to_index)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(values, field_to_index)Initialize self.
get
(key[, default])Return a value for key, with a default value if it does not exist.
items
()Return items as
(key, value)
pairs.keys
()Return the keys for using a row as a dict.
values
()Return the values included in this row.
-
get
(key, default=None)[source]¶ Return a value for key, with a default value if it does not exist.
- Parameters
- Returns
The value associated with the provided key, or a default value.
- Return type
Examples
When the key exists, the value associated with it is returned.
>>> Row(('a', 'b'), {'x': 0, 'y': 1}).get('x') 'a'
The default value is
None
when the key does not exist.>>> Row(('a', 'b'), {'x': 0, 'y': 1}).get('z') None
The default value can be overrided with the
default
parameter.>>> Row(('a', 'b'), {'x': 0, 'y': 1}).get('z', '') ''
>>> Row(('a', 'b'), {'x': 0, 'y': 1}).get('z', default = '') ''
-
items
()[source]¶ Return items as
(key, value)
pairs.Examples
>>> list(Row(('a', 'b'), {'x': 0, 'y': 1}).items()) [('x', 'a'), ('y', 'b')]