Cast array values to another data type. Can also be invoked as an array instance method.
DataType
or str
Type to cast to
True
Check for overflows or other unsafe conversions
CastOptions
, default None
Additional checks pass by CastOptions
MemoryPool
, optional
memory pool to use for allocations during function execution.
Array
The cast result as a new Array
Examples
>>> from datetime import datetime >>> import pyarrow as pa >>> arr = pa.array([datetime(2010, 1, 1), datetime(2015, 1, 1)]) >>> arr.type TimestampType(timestamp[us])
You can use pyarrow.DataType
objects to specify the target type:
>>> cast(arr, pa.timestamp('ms')) <pyarrow.lib.TimestampArray object at ...> [ 2010-01-01 00:00:00.000, 2015-01-01 00:00:00.000 ]
>>> cast(arr, pa.timestamp('ms')).type TimestampType(timestamp[ms])
Alternatively, it is also supported to use the string aliases for these types:
>>> arr.cast('timestamp[ms]') <pyarrow.lib.TimestampArray object at ...> [ 2010-01-01 00:00:00.000, 2015-01-01 00:00:00.000 ] >>> arr.cast('timestamp[ms]').type TimestampType(timestamp[ms])
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4