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 boto3 | |
import requests | |
import time | |
url = ( | |
"https://min-api.cryptocompare.com/data/pricemulti?fsyms=BTC,ETH,REP,DASH&tsyms=USD" | |
) | |
r = requests.get(url) | |
data = r.json() | |
print(data) |
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
aws timestream-write create-database --database-name demo |
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
aws timestream-write create-table \ | |
--database-name=demo --table-name data \ | |
--retention-properties=MemoryStoreRetentionPeriodInHours=1,MagneticStoreRetentionPeriodInDays=365 |
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
aws timestream-write write-records --database-name demo --table data --generate-cli-skeleton |
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
aws timestream-write write-records --database-name demo --table data --cli-input-json file://crypto.json |
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 json | |
cli = dict(DatabaseName="demo", TableName="data", Records=records) | |
with open("crypto.json", "w") as f: | |
json.dump(cli, f) |
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 awswrangler as wr | |
db = "demo" | |
table = "data" | |
db_response = wr.timestream.create_database(db) | |
print(db_response) | |
# returns ARN of that database: arn:aws:timestream:us-east-1:XXX:database/demo | |
tbl_response = wr.timestream.create_table( | |
db, table, memory_retention_hours=1, magnetic_retention_days=365 | |
) |
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
from datetime import date | |
import pandas_datareader.data as web | |
df = web.DataReader("AAPL", "av-daily", start=date(2021, 10, 1), end=date.today()) |
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
from datetime import date, datetime | |
import pandas_datareader.data as web | |
import pandas as pd | |
import awswrangler as wr | |
df = web.DataReader("AAPL", "av-daily", start=date(2021, 10, 1), end=date.today()) | |
df = df.reset_index(drop=False) | |
df = df.rename(columns={"index": "dt"}) | |
df.dt = pd.to_datetime(df.dt) |
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 prefect | |
from prefect import Flow, Parameter | |
from prefect.executors import DaskExecutor | |
def dynamic_executor(): | |
from distributed import LocalCluster | |
# could be instead some other class e.g. from dask_cloudprovider.aws import FargateCluster | |
return LocalCluster(n_workers=prefect.context.parameters["n_workers"]) |