'How to write dataframe columns as a YAML file

I have dataframe like this:

class    params
classA   {'key1':value1,'key2':value2,'key3':value3}

I want to generate a yaml file like this:

class: class A
params:
  key1: value1
  key2: value2
  key3: value3

How can I do this in efficient way?



Sources

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

Source: Stack Overflow

Solution Source