how to convert the dictionary with the list item to the pandas.Series?

Question:

data_dict = {'A': [1,3,3], 'B': [2,3,3]} 

convert to

A 1  
A 3  
A 3  
B 2  
B 3  
B 3  

I tried to loop, but it is not simple enough. Is there any more simple method?

Asked By: DZN

||

Answers:

data_dict = {'A': [1,3,3], 'B': [2,3,3]}
s = pd.Series(data_dict).explode()
print(s)
A    1
A    3
A    3
B    2
B    3
B    3
dtype: object
Answered By: Алексей Р
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.