Skip to content

Instantly share code, notes, and snippets.

View ameliagreenhall's full-sized avatar

Amelia Greenhall ameliagreenhall

View GitHub Profile
@ameliagreenhall
ameliagreenhall / df2json.py
Last active December 12, 2015 03:39 — forked from mikedewar/df2json.py
Convert a pandas dataframe to a json blob
"""
tiny script to convert a pandas data frame into a JSON object
orig: https://gist.github.com/1486027 via Mike Dewar
Test data:
df = pandas.DataFrame({
"time" : [1,2,3,4,5],
"temp" : np.random.rand(5)
})
"""
tiny script to convert a pandas data frame into a JSON object
"""
import ujson as json
import pandas
import numpy as np
df = pandas.DataFrame({
"time" : [1,2,3,4,5],