Cast to a NumPy array or ExtensionArray with âdtypeâ.
Typecode or data-type to which the array is cast.
Whether to copy the data, even if not necessary. If False, a copy is made only if the old dtype does not match the new dtype.
An ExtensionArray
if dtype
is ExtensionDtype
, otherwise a Numpy ndarray with dtype
for its dtype.
Examples
>>> arr = pd.array([1, 2, 3]) >>> arr <IntegerArray> [1, 2, 3] Length: 3, dtype: Int64
Casting to another ExtensionDtype
returns an ExtensionArray
:
>>> 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')
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