Skip to content

Instantly share code, notes, and snippets.

@roscopecoltran
Forked from nackjicholson/pandas-json-yaml.py
Created November 18, 2017 16:37
Show Gist options
  • Save roscopecoltran/4efb1ccc4056e6d3c43c697463624baf to your computer and use it in GitHub Desktop.
Save roscopecoltran/4efb1ccc4056e6d3c43c697463624baf to your computer and use it in GitHub Desktop.
import yaml
import json
import pandas as pd
df = pd.DataFrame({'one': [1.0, 2.1, 3.2], 'two': [4.3, 5.4, 6.5]})
with open('df.yml', 'w') as file:
yaml.dump({'result': json.loads(df.to_json(orient='records'))}, file, default_flow_style=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment