Created
August 11, 2015 14:33
-
-
Save jseabold/9004454ac4140845f1de to your computer and use it in GitHub Desktop.
Plot EC2 spot pricing with boto3 and pandas
This file contains 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 pandas as pd | |
from boto3 import client | |
client = client(service_name='ec2') | |
prices = client.describe_spot_price_history(InstanceTypes=["m3.medium"], | |
AvailabilityZone="us-east-1a") | |
df = pd.DataFrame(prices['SpotPriceHistory']) | |
df.set_index("Timestamp", inplace=True) | |
df["SpotPrice"] = df.SpotPrice.astype(float) | |
df = df.sort_index() | |
week_ago = pd.datetime.now() - pd.datetools.Day(7) | |
twice_daily = df.ix[week_ago:].resample("12h") | |
twice_daily.SpotPrice.plot() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment