Skip to content

Instantly share code, notes, and snippets.

@timothymugayi
Created July 29, 2020 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timothymugayi/e098d947c0269981055c70bee1c58761 to your computer and use it in GitHub Desktop.
Save timothymugayi/e098d947c0269981055c70bee1c58761 to your computer and use it in GitHub Desktop.
import os
import math
import dask.dataframe as dd
import numpy as np
import pandas as pd
from dask.distributed import Client
client = Client('tcp://scheduler:8786')
# Lets toggle localstack by changing where boto3 is pointing to
if os.environ.get('LOCALSTACK_S3_ENDPOINT_URL'):
taxi_data = dd.read_csv( 's3://nyc-tlc/trip data/yellow_tripdata_2018-04.csv',
storage_options={
'anon': True,
'use_ssl': False,
'key': 'foo',
'secret': 'bar',
"client_kwargs": {
"endpoint_url": os.environ.get('LOCALSTACK_S3_ENDPOINT_URL'),
"region_name": "us-east-1"
}
}
)
else:
# This assumes your using named profiles in aws cli with a default profile accessing your s3 bucket or EC2
# instance or ECS task role
taxi_data = dd.read_csv('s3://nyc-tlc/trip data/yellow_tripdata_2018-04.csv')
taxi_data.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment