Pandas: Create Series from dictionary in python – thisPointer

PHOTO EMBED

Mon Jan 24 2022 01:44:51 GMT+0000 (Coordinated Universal Time)

Saved by @ask4med #python

import pandas as pd

# Dictionary of string and int
char_dict = {
    'C': 56,
    "A": 23,
    'D': 43,
    'E': 78,
    'B': 11
}

# Convert a dictionary to a Pandas Series object.
# dict keys will be index of Series &
# values of dict will become values in Series.
series_obj = pd.Series(char_dict)

print('Contents of Pandas Series: ')
print(series_obj)
content_copyCOPY

https://thispointer.com/pandas-create-series-from-dictionary-in-python/