In this python pandas program, we will convert a NumPy array to a Pandas series.
Steps to solve the program
- Import pandas library as pd.
- Import NumPy library as np.
- Create a NumPy array using np.array().
- Now convert that array to a Pandas series using pd.Series().
- Print the output.
import numpy as np
import pandas as pd
array = np.array([5,3,8,9,0])
result = pd.Series(array)
print(result)
Output :
0 5
1 3
2 8
3 9
4 0
dtype: int32