Skip to main content

Library to handle JSON-stat data in python using pandas DataFrames.

Project description

pyjstat is a python library for JSON-stat formatted data manipulation which allows reading and writing JSON-stat [1] format with python,using the DataFrame structures provided by the widely accepted pandas library [2]. The JSON-stat format is a simple lightweight JSON format for data dissemination. Pyjstat is inspired in rjstat [3], a library to read and write JSON-stat with R, by ajschumacher. Note that, like in the rjstat project, not all features are supported (i.e. not all metadata are converted). pyjstat is provided under the Apache License 2.0.

[1] for JSON-stat information
[2] for Python Data Analysis Library information
[3] for rjstat library information

This library was first developed to work with Python 2.7. With some fixes (thanks to @andrekittredge), now it works with Python 3.4 too.


pyjstat requires pandas package. For installation:

pip install pyjstat


From JSON-stat to pandas DataFrame

Typical usage often looks like this:

from pyjstat import pyjstat
import requests
from collections import OrderedDict

data = requests.get('')
results = pyjstat.from_json_stat(data.json(object_pairs_hook=OrderedDict))
print (results)

From pandas DataFrame to JSON-stat

The same data can be converted into JSON-stat, with some unavoidable metadata loss:

from pyjstat import pyjstat
import urllib2
import json

data = requests.get('')
results = pyjstat.from_json_stat(data.json(object_pairs_hook=OrderedDict))
print (pyjstat.to_json_stat(results))

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyjstat, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size pyjstat-0.2.0.tar.gz (171.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page