Python Practice › Pandas Programs › Program 10
NumPy array to Series
Write a pandas program to convert a NumPy array to a Series.
Input
[5, 3, 8, 9, 0]
Output
0 5 1 3 2 8 3 9 4 0 dtype: int64
Approach
pd.Series(array).
Solution
import numpy as npimport pandas as pdprint(pd.Series(np.array([5, 3, 8, 9, 0])))Output
0 5 1 3 2 8 3 9 4 0 dtype: int64
Learn the concept
New to this topic? Read the lesson, then come back.