pandas.Series.values#

property Series.values[源代码]#

根据 dtype 不同,将 Series 返回为 ndarray 或类似 ndarray的对象。

警告

我们建议使用 Series.arraySeries.to_numpy() ,具体取决于您是需要底层数据的引用还是 NumPy 数组。

Returns:
numpy.ndarray 或类 ndarray

参见

Series.array

底层数据的引用。

Series.to_numpy

表示底层数据的 NumPy 数组。

Examples

>>> pd.Series([1, 2, 3]).values
array([1, 2, 3])
>>> pd.Series(list('aabc')).values
array(['a', 'a', 'b', 'c'], dtype=object)
>>> pd.Series(list('aabc')).astype('category').values
['a', 'a', 'b', 'c']
Categories (3, object): ['a', 'b', 'c']

带时区的日期时间数据将被转换为 UTC:

>>> pd.Series(pd.date_range('20130101', periods=3,
...                         tz='US/Eastern')).values
array(['2013-01-01T05:00:00.000000000',
       '2013-01-02T05:00:00.000000000',
       '2013-01-03T05:00:00.000000000'], dtype='datetime64[ns]')