'Pandas series with dictionary to string or json format

I have a pandas series containing values of type dict. I have used ast.literal_eval to turn string or json into dict.

I am looking to do the reverse now. How do I turn dict into string? Sample data for reference:

import pandas as pd

df = pd.DataFrame({'d': [{'a': 1, 'b': 2}, {'c': 3, 'd': 4}] })


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source