Below is a python program to convert a dictionary to a Pandas series. We have executed the below program and added the program output.
1 2 3 4 5 6 7 | import pandas as pd d1 = {'a': 50, 'b': 100, 'c':150, 'd':200, 'e':500} print("Original dictionary:") print(d1) new_series = pd.Series(d1) print("Converted series:") print(new_series) |
Program Output:
1 2 3 4 5 6 7 8 9 | Original dictionary: {'a': 50, 'b': 100, 'c': 150, 'd': 200, 'e': 500} Converted series: a 50 b 100 c 150 d 200 e 500 dtype: int64 |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.