Instantly share code, notes, and snippets.

What would you like to do?
Plot EC2 spot pricing with boto3 and pandas
import pandas as pd
from boto3 import client
client = client(service_name='ec2')
prices = client.describe_spot_price_history(InstanceTypes=["m3.medium"],
df = pd.DataFrame(prices['SpotPriceHistory'])
df.set_index("Timestamp", inplace=True)
df["SpotPrice"] = df.SpotPrice.astype(float)
df = df.sort_index()
week_ago = - pd.datetools.Day(7)
twice_daily = df.ix[week_ago:].resample("12h")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment