Python Practice › Pandas Programs › Program 12
Series to array
Write a pandas program to convert a Series to a NumPy array.
Input
["54", "27.90", "sqa", "33.33", "tools"]
Output
['54' '27.90' 'sqa' '33.33' 'tools']
Approach
to_numpy().
Solution
import pandas as pdprint(pd.Series(["54", "27.90", "sqa", "33.33", "tools"]).to_numpy())Output
['54' '27.90' 'sqa' '33.33' 'tools']
Learn the concept
New to this topic? Read the lesson, then come back.