bigframes.pandas.Series.to_numpy#
- Series.to_numpy(dtype=None, copy=False, na_value=<no_default>, *, allow_large_results=None, **kwargs) ndarray[source]#
A NumPy ndarray representing the values in this Series or Index.
Examples:
>>> ser = bpd.Series(pd.Categorical(['a', 'b', 'a'])) >>> ser.to_numpy() array(['a', 'b', 'a'], dtype=object)
Specify the dtype to control how datetime-aware data is represented. Use dtype=object to return an ndarray of pandas Timestamp objects, each with the correct tz.
>>> ser = bpd.Series(pd.date_range('2000', periods=2, tz="CET")) >>> ser.to_numpy(dtype=object) array([Timestamp('1999-12-31 23:00:00+0000', tz='UTC'), Timestamp('2000-01-01 23:00:00+0000', tz='UTC')], dtype=object)
Or
dtype=datetime64[ns]to return an ndarray of native datetime64 values. The values are converted to UTC and the timezone info is dropped.>>> ser.to_numpy(dtype="datetime64[ns]") array(['1999-12-31T23:00:00.000000000', '2000-01-01T23:00:00.000000000'], dtype='datetime64[ns]')
- Parameters:
dtype (str or numpy.dtype, optional) – The dtype to pass to
numpy.asarray().copy (bool, default False) – Whether to ensure that the returned value is not a view on another array. Note that
copy=Falsedoes not ensure thatto_numpy()is no-copy. Rather,copy=Trueensure that a copy is made, even if not strictly necessary.na_value (Any, optional) – The value to use for missing values. The default value depends on dtype and the type of the array.
allow_large_results (bool, default None) – If not None, overrides the global setting to allow or disallow large query results over the default size limit of 10 GB.
**kwargs – Additional keywords passed through to the
to_numpymethod of the underlying array (for extension arrays).
- Returns:
A NumPy ndarray representing the values in this Series or Index.
- Return type:
numpy.ndarray