HOWTO · NumPy

How to Convert Pandas Series to NumPy Array

Convert the values of a pandas Series to a NumPy array with Series.to_numpy(), and choose compatible alternatives while keeping the index separate.

On this page

A pandas Series stores values together with an index of labels. To get a NumPy array of the values, call Series.to_numpy() on the Series itself. The labels are not included; keep or convert the index separately if your next step needs it.

Convert a pandas Series to a NumPy array with Series.to_numpy()

Series.to_numpy() is the direct choice when a NumPy ndarray is required. The example creates a Series with two numeric values and labels, converts the Series values, and inspects the resulting array and dtype. It prints the values [82 91] and reports the array dtype as int64.

Run this example:

import pandas as pd

scores = pd.Series([82, 91], index=["Mia", "Noah"], name="score")
values = scores.to_numpy()
print(values)
print(values.dtype)
[82 91]
int64

The array contains the values in Series order. It does not contain "Mia" or "Noah"; those labels remain on scores.index. This distinction matters when passing values to a NumPy operation, where positional order is used and pandas labels are not carried along.

Use Series.array when you need pandas’ extension array

Use Series.array when the next operation should receive pandas’ array representation. Depending on the Series data, that representation can be an extension array rather than a NumPy ndarray. Extension arrays preserve pandas-specific value behavior for data types that do not map directly to a conventional NumPy dtype. If the receiving API specifically requires an ndarray, use Series.to_numpy() instead.

For example, the expression scores.array accesses the Series array representation, while scores.to_numpy() requests the NumPy representation. These choices serve different consumers; do not assume that the result of Series.array is an ndarray or pass it to an API that requires one without checking its requirements.

Use Series.values or numpy.asarray() for compatible alternatives

Series.values is a concise alternative for obtaining the Series values as an array-like object. Its exact result can depend on the Series dtype, so use Series.to_numpy() when you want the explicit conversion method and NumPy ndarray result. numpy.asarray(scores) is another compatible way to request an array from a Series; it is useful when working with NumPy code that already accepts array-like inputs.

These forms address the Series values, not the Series labels. Choose based on the contract of the code that consumes the result: use Series.to_numpy() for a clear ndarray conversion, Series.array for pandas’ array representation, or Series.values and numpy.asarray() when those compatible forms fit the surrounding code. None of these choices converts the index into the values array.

Check the array result and handle index and dtype separately

Inspect the result when dtype affects later calculations or storage. A numeric Series generally produces a numeric NumPy dtype; data represented by pandas-specific or mixed values may require a different NumPy representation. Check values.dtype for the actual result in your data rather than assuming every Series becomes the same kind of array. No optional dtype or copy controls are shown here because the supplied task evidence does not establish Series-specific version guidance.

If labels are also needed, access scores.index separately and keep the relationship between labels and values explicit in your program. Converting only the values discards label-based alignment from subsequent NumPy operations. This is often the intended behavior for numerical processing, but code that combines values from multiple Series should first confirm that their ordering matches. A Series-to-array conversion does not align two Series by their labels for you.