Introduction to AWS Boto in Python
Maksim Pecherskiy
Data Engineer
Convert DataFrame to html
df.to_html('table_agg.html')
Convert DataFrame to html
df.to_html('table_agg.html', render_links=True)
Convert DataFrame to html
df.to_html('table_agg.html',
render_links=True,
columns['service_name', 'request_count', 'info_link'])
Convert DataFrame to html
df.to_html('table_agg.html',
render_links=True,
columns['service_name', 'request_count', 'info_link'],
border=0)
Upload an HTML file to S3
s3.upload_file( Filename='./table_agg.html', Bucket='datacamp-website',
Key='table.html',
ExtraArgs = { 'ContentType': 'text/html', 'ACL': 'public-read'} )
S3 Object URL Template
https://{bucket}.{key}
https://datacamp-website.table.html
Upload an image file to S3
s3.upload_file( Filename='./plot_image.png', Bucket='datacamp-website', Key='plot_image.png',
ExtraArgs = { 'ContentType': 'image/png', 'ACL': 'public-read'} )
application/json
image/png
application/pdf
text/csv
# List the gid-reports bucket objects starting with 2019/ r = s3.list_objects(Bucket='gid-reports', Prefix='2019/')
# Convert the response contents to DataFrame objects_df = pd.DataFrame(r['Contents'])
# Create a column "Link" that contains website url + key
base_url = "http://datacamp-website."
objects_df['Link'] = base_url + objects_df['Key']
# Write DataFrame to html
objects_df.to_html('report_listing.html',
columns=['Link', 'LastModified', 'Size'],
render_links=True)
Upload an HTML file to S3
s3.upload_file(
Filename='./report_listing.html',
Bucket='datacamp-website',
Key='index.html',
ExtraArgs = {
'ContentType': 'text/html',
'ACL': 'public-read'}
)
df.to_html('table.html')
)ContentType: text/html
)ContentType: image/png
)Introduction to AWS Boto in Python