Pandas Series is a one-dimensional labeled array capable of holding data of any type (integer, string, float, python objects, etc.).
Let’s see how can we create a Pandas Series using different numpy
functions.
Code #1: Using numpy.linspace()
import pandas as pd
import numpy as np
ser1 = pd.Series(np.linspace( 3 , 33 , 3 ))
print (ser1)
ser2 = pd.Series(np.linspace( 1 , 100 , 10 ))
print ( "\n" , ser2)
|
Output:

Code #2: Using np.random.normal() and random.rand() method.
import pandas as pd
import numpy as np
ser3 = pd.Series(np.random.normal())
print (ser3)
ser4 = pd.Series(np.random.normal( 0.0 , 1.0 , 5 ))
print ( "\n" , ser4)
ser5 = pd.Series(np.random.rand( 10 ))
print ( "\n" , ser5)
|
Output:


Code #3: Using numpy.repeat()
import pandas as pd
import numpy as np
ser = pd.Series(np.repeat( 0.08 , 7 ))
print ( "\n" , ser)
|
Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
18 Dec, 2018
Like Article
Save Article