Python Practice › Pandas Programs › Program 10

NumPy array to Series

EasyPandas Programs · 10 of 95

Write a pandas program to convert a NumPy array to a Series.

Advertisement
Input
[5, 3, 8, 9, 0]
Output
0    5
1    3
2    8
3    9
4    0
dtype: int64

Approach

  1. pd.Series(array).

Solution

Python
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
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More pandas programs

← All 95 Pandas Programs