How will you create a series from dict in Pandas?

Answer

A Series is defined as a one-dimensional array that is capable of storing various data types.

We can create a Pandas Series from Dictionary:

 

Create a Series from dict:

We can also create a Series from dict. If the dictionary object is being passed as an input and the index is not specified, then the dictionary keys are taken in a sorted order to construct the index.

If index is passed, then values correspond to a particular label in the index will be extracted from the dictionary.

 
  1. import pandas as pd    
  2. import numpy as np    
  3. info = {'x' : 0., 'y' : 1., 'z' : 2.}    
  4. a = pd.Series(info)    
  5. print (a)    

Output:

x     0.0
y     1.0
z     2.0
dtype: float64

All pandas Questions

Ask your interview questions on pandas

Write Your comment or Questions if you want the answers on pandas from pandas Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---