Created
August 28, 2017 22:01
-
-
Save bo01ean/62dc806b7368b43be6c2a973bc8dfaac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
import inspect | |
import os | |
import datetime as dt | |
import pylab | |
import subprocess | |
import tempfile | |
import plotly.plotly as py | |
import plotly.graph_objs as go | |
import urllib.request | |
import numpy as np | |
import plotly | |
import json | |
import boto3 | |
import re | |
plotly.tools.set_credentials_file(username='*****', api_key='******') | |
try: | |
from itertools import izip | |
except ImportError: | |
izip = zip | |
columns = ['instance_type', 'pricing'] | |
region = 'us-east-1' | |
def execute(cmd): | |
return subprocess.check_output(cmd.split()) | |
frame = inspect.getfile(inspect.currentframe()) | |
path = os.path.dirname(os.path.abspath(frame)) | |
os.chdir("/Users/NathanTrujillo/Documents/gits/ec2instances.info") | |
checkout = "git checkout {}" | |
# get git history for file | |
subprocess.check_output(r"git log --all --pretty=format:'%h,%cd' -- www/instances.json > instanceCommitHistory.csv".split()) | |
df = pd.read_csv('instanceCommitHistory.csv', delimiter=',') | |
df.columns = ['hash', 'date'] | |
# make string date be date type | |
df['date'] = pd.to_datetime(df['date']) | |
history = {} | |
hashes = [] | |
# now iterate through all hashes, and store the data in memory | |
for index, row in df.iterrows(): | |
print(row['hash']) | |
date = pd.to_datetime(row['date']) | |
hashes.append(date) | |
execute(checkout.format(row['hash'])) | |
data = pd.read_json('www/instances.json') | |
data = data[columns] | |
data['pricing'] = data['pricing'].to_frame() | |
#data['pricing'] = data['pricing'][region] | |
history[date] = data | |
mega = pd.concat(history) | |
history[hashes[0]] | |
# extract region | |
slot = history[hashes[0]]['pricing'].to_frame() | |
slot['pricing'] = slot['pricing'].to_frame() | |
slot | |
#print(slot['pricing'][0][region]) | |
mega.to_json('history.json') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment