diff --git a/bigquery/google/cloud/bigquery/table.py b/bigquery/google/cloud/bigquery/table.py index ce68e18ef7356..4bbc4c3ec380f 100644 --- a/bigquery/google/cloud/bigquery/table.py +++ b/bigquery/google/cloud/bigquery/table.py @@ -783,22 +783,38 @@ def __init__(self, values, field_to_index): self._xxx_field_to_index = field_to_index def values(self): + """Return the values included in this row. + + Returns: + Sequence[object]: A sequence of length ``len(row)``. + """ return self._xxx_values def keys(self): - """ - Return keys as of a dict: - >>> Row(('a', 'b'), {'x': 0, 'y': 1}).keys() - ['x', 'y'] + """Return the keys for using a row as a dict. + + Returns: + Sequence[str]: The keys corresponding to the columns of a row + + Examples: + + >>> Row(('a', 'b'), {'x': 0, 'y': 1}).keys() + ['x', 'y'] """ keys = self._xxx_field_to_index.keys() return keys def items(self): - """ - Return items as of a dict: - >>> Row(('a', 'b'), {'x': 0, 'y': 1}).items() - [('x', 'a'), ('y', 'b')] + """Return items as ``(key, value)`` pairs. + + Returns: + Sequence[Tuple[str, object]]: + The ``(key, value)`` pairs representing this row. + + Examples: + + >>> Row(('a', 'b'), {'x': 0, 'y': 1}).items() + [('x', 'a'), ('y', 'b')] """ items = [ (k, self._xxx_values[i]) @@ -808,18 +824,38 @@ def items(self): return items def get(self, key, default=None): - """ - Return value under specified key - Defaults to None or specified default - if key does not exist: - >>> Row(('a', 'b'), {'x': 0, 'y': 1}).get('x') - 'a' - >>> Row(('a', 'b'), {'x': 0, 'y': 1}).get('z') - None - >>> Row(('a', 'b'), {'x': 0, 'y': 1}).get('z', '') - '' - >>> Row(('a', 'b'), {'x': 0, 'y': 1}).get('z', default = '') - '' + """Return value for ``key`` if ``key`` is in the row, else + ``default``. + + Args: + key (str): The key of the column to access + + default (object): + The default value to use if the key does not exist. (Defaults + to ``None``.) + + Returns: + object: + The value associated with the provided key, or a default value. + + 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 = '') + '' """ index = self._xxx_field_to_index.get(key) if index is None: