Skip to content

Instantly share code, notes, and snippets.

@sdhutchins
Forked from nackjicholson/pandas-json-yaml.py
Created April 18, 2017 19:07
Show Gist options
  • Save sdhutchins/e831537c8c3916f32a4fd8a167e0e9ce to your computer and use it in GitHub Desktop.
Save sdhutchins/e831537c8c3916f32a4fd8a167e0e9ce 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