Skip to content

Instantly share code, notes, and snippets.

View ameliagreenhall's full-sized avatar

Amelia Greenhall ameliagreenhall

View GitHub Profile
"""
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],
@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)
})
@ameliagreenhall
ameliagreenhall / 401k_plan_data.json
Last active December 12, 2015 05:08
401k Fees Differ by Company Size
[{"fee": 214.65468750000002, "size": 18510.0, "aum": 1290075671.0, "name": "Google Inc.", "er": 0.2828125}, {"fee": 275.45375000000035, "size": 14783.0, "aum": 379903275.0, "name": "Amazon Corporate LLC", "er": 0.3629166666666671}, {"fee": 590.7958064516133, "size": 896.0, "aum": 23790796.0, "name": "Facebook Inc.", "er": 0.778387096774194}, {"fee": 511.7257894736838, "size": 1322.0, "aum": 99473103.0, "name": "F5 Networks Inc.", "er": 0.6742105263157889}, {"fee": 178.6569230769228, "size": 6412.0, "aum": 595350786.0, "name": "Adobe Systems Incorporated", "er": 0.235384615384615}, {"fee": 550.1024999999998, "size": 367.0, "aum": 5683051.0, "name": "Zynga Game Network Inc.", "er": 0.724772727272727}, {"fee": 330.76421052631616, "size": 1358.0, "aum": 68449266.0, "name": "Getty Images Inc.", "er": 0.435789473684211}, {"fee": 456.3730769230767, "size": 5474.0, "aum": 190340683.0, "name": "Expedia Inc.", "er": 0.601282051282051}, {"fee": 134.9333333333335, "size": 13325.0, "aum": 1540276000.0, "name": "Weyerhaeus
@ameliagreenhall
ameliagreenhall / account_balances.json
Last active December 14, 2015 03:29
Savings at Different Companies after 401k Fees
[{"total_participants": 4400000.0, "average_plan_option_fee": 0.0249, "url": "https://futureadvisor.com/401k/thrift-savings-plan", "group_nm": 1, "balance_final": 859089.2618991669, "net_assets": 281000000000.0, "foregone_earnings": 1765.9056077526911, "parameterized_name": "thrift-savings-plan", "company_name": "Thrift Savings Plan", "timeseries": [{"balance": 5500.0, "time": 2013}, {"balance": 11389.074350499999, "time": 2014}, {"balance": 17688.024248297181, "time": 2015}, {"balance": 24418.646847399988, "time": 2016}, {"balance": 31603.780290112718, "time": 2017}, {"balance": 39267.350706372119, "time": 2018}, {"balance": 47434.421265533623, "time": 2019}, {"balance": 56131.24336835547, "time": 2020}, {"balance": 65385.31007062766, "time": 2021}, {"balance": 75225.411833746126, "time": 2022}, {"balance": 85681.694701546367, "time": 2023}, {"balance": 96785.72100689233, "time": 2024}, {"balance": 108570.53271587242, "time": 2025}, {"balance": 121070.71752199205, "time": 2026}, {"balance": 134322.4778074786
@ameliagreenhall
ameliagreenhall / accounting.min.js
Last active December 14, 2015 20:40
401k Fees across Companies, Expanded
/*!
* accounting.js v0.3.2, copyright 2011 Joss Crowcroft, MIT license, http://josscrowcroft.github.com/accounting.js
*/
(function(p,z){function q(a){return!!(""===a||a&&a.charCodeAt&&a.substr)}function m(a){return u?u(a):"[object Array]"===v.call(a)}function r(a){return"[object Object]"===v.call(a)}function s(a,b){var d,a=a||{},b=b||{};for(d in b)b.hasOwnProperty(d)&&null==a[d]&&(a[d]=b[d]);return a}function j(a,b,d){var c=[],e,h;if(!a)return c;if(w&&a.map===w)return a.map(b,d);for(e=0,h=a.length;e<h;e++)c[e]=b.call(d,a[e],e,a);return c}function n(a,b){a=Math.round(Math.abs(a));return isNaN(a)?b:a}function x(a){var b=c.settings.currency.format;"function"===typeof a&&(a=a());return q(a)&&a.match("%v")?{pos:a,neg:a.replace("-","").replace("%v","-%v"),zero:a}:!a||!a.pos||!a.pos.match("%v")?!q(b)?b:c.settings.currency.format={pos:b,neg:b.replace("%v","-%v"),zero:b}:a}var c={version:"0.3.2",settings:{currency:{symbol:"$",format:"%s%v",decimal:".",thousand:",",precision:2,grouping:3},number:{precision:0,grouping
@ameliagreenhall
ameliagreenhall / Examples for Creating JSON from Pandas DataFrames.ipynb
Created April 30, 2013 22:02
Series to Json for nested d3 blobs - iPython Notebook file
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ameliagreenhall
ameliagreenhall / README.md
Last active December 17, 2015 17:59
force layout map of my current interests, aspirations
@ameliagreenhall
ameliagreenhall / keybase.md
Created November 29, 2017 03:30
keybase.md

Keybase proof

I hereby claim:

  • I am ameliagreenhall on github.
  • I am ameliagreenhall (https://keybase.io/ameliagreenhall) on keybase.
  • I have a public key ASBHdX_1icvDnLV3s_D6wA1Quh74EJFO8x9QB_TaPkzXRwo

To claim this, I am signing this object: