API Reference¶
Pandas Data Types for SQL systems (BigQuery, Spanner)
- class db_dtypes.DateArray(values, dtype=None, copy: bool = False)[source]¶
Pandas array type containing date data
- astype(dtype, copy=True)[source]¶
Cast to a NumPy array or ExtensionArray with ‘dtype’.
- Parameters
- Returns
An
ExtensionArray
ifdtype
isExtensionDtype
, otherwise a Numpy ndarray withdtype
for its dtype.- Return type
np.ndarray or pandas.api.extensions.ExtensionArray
Examples
>>> arr = pd.array([1, 2, 3]) >>> arr <IntegerArray> [1, 2, 3] Length: 3, dtype: Int64
Casting to another
ExtensionDtype
returns anExtensionArray
:>>> arr1 = arr.astype('Float64') >>> arr1 <FloatingArray> [1.0, 2.0, 3.0] Length: 3, dtype: Float64 >>> arr1.dtype Float64Dtype()
Otherwise, we will get a Numpy ndarray:
>>> arr2 = arr.astype('float64') >>> arr2 array([1., 2., 3.]) >>> arr2.dtype dtype('float64')
- class db_dtypes.DateDtype[source]¶
Extension dtype for time data.
- static __from_arrow__(array: Union[pyarrow.lib.Array, pyarrow.lib.ChunkedArray]) → db_dtypes.DateArray[source]¶
Convert to dbdate data from an Arrow array.
- construct_array_type()[source]¶
Return the array type associated with this dtype.
- Returns
- Return type
- type¶
alias of
datetime.date
- class db_dtypes.TimeArray(values, dtype=None, copy: bool = False)[source]¶
Pandas array type containing time data
- astype(dtype, copy=True)[source]¶
Cast to a NumPy array or ExtensionArray with ‘dtype’.
- Parameters
- Returns
An
ExtensionArray
ifdtype
isExtensionDtype
, otherwise a Numpy ndarray withdtype
for its dtype.- Return type
np.ndarray or pandas.api.extensions.ExtensionArray
Examples
>>> arr = pd.array([1, 2, 3]) >>> arr <IntegerArray> [1, 2, 3] Length: 3, dtype: Int64
Casting to another
ExtensionDtype
returns anExtensionArray
:>>> arr1 = arr.astype('Float64') >>> arr1 <FloatingArray> [1.0, 2.0, 3.0] Length: 3, dtype: Float64 >>> arr1.dtype Float64Dtype()
Otherwise, we will get a Numpy ndarray:
>>> arr2 = arr.astype('float64') >>> arr2 array([1., 2., 3.]) >>> arr2.dtype dtype('float64')
- class db_dtypes.TimeDtype[source]¶
Extension dtype for time data.
- static __from_arrow__(array: Union[pyarrow.lib.Array, pyarrow.lib.ChunkedArray]) → db_dtypes.TimeArray[source]¶
Convert to dbtime data from an Arrow array.
- construct_array_type()[source]¶
Return the array type associated with this dtype.
- Returns
- Return type
- type¶
alias of
datetime.time