Articles → Pandas → Series in pandas

Series in pandas






What is a series in pandas?





Example




import pandas as pd
my_list = [10,20,30]
pd.Series(my_list)




Click to Enlarge


Customizing the labels in series




import pandas as pd

my_list = [10,20,30]
labels = ['I', 'II', 'III']
pd.Series(my_list, labels)


Click to Enlarge








Converting NumPy array to series




import numpy as np
import pandas as pd

my_list = [10,20,30]
arr = np.array(my_list)

pd.Series(arr)


Click to Enlarge


Converting dictionary into series




import pandas as pd

d = {'a':10,'b':20,'c':30}
pd.Series(d)




Click to Enlarge


Print series




import numpy as np
import pandas as pd


d = {'a':10,'b':20,'c':30}

ser = pd.Series(d)

# Printing the series
print(ser['a'])





Using labels as data





Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, April 10, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250