Python 中的 AWS Boto 入门
Maksim Pecherskiy
Data Engineer

将 DataFrame 转为 HTML
df.to_html('table_agg.html')

将 DataFrame 转为 HTML
df.to_html('table_agg.html', render_links=True)

将 DataFrame 转为 HTML
df.to_html('table_agg.html',
render_links=True,
columns['service_name', 'request_count', 'info_link'])

将 DataFrame 转为 HTML
df.to_html('table_agg.html',
render_links=True,
columns['service_name', 'request_count', 'info_link'],
border=0)

将 HTML 文件上传到 S3
s3.upload_file( Filename='./table_agg.html', Bucket='datacamp-website',Key='table.html',ExtraArgs = { 'ContentType': 'text/html', 'ACL': 'public-read'} )
S3 对象 URL 模板
https://{bucket}.{key}
https://datacamp-website.table.html

将图像文件上传到 S3
s3.upload_file( Filename='./plot_image.png', Bucket='datacamp-website', Key='plot_image.png',ExtraArgs = { 'ContentType': 'image/png', 'ACL': 'public-read'} )
application/jsonimage/png application/pdf text/csv# 列出 gid-reports 存储桶中以 2019/ 开头的对象 r = s3.list_objects(Bucket='gid-reports', Prefix='2019/')# 将响应内容转换为 DataFrame objects_df = pd.DataFrame(r['Contents'])

# 创建包含网站 URL + key 的"Link"列
base_url = "http://datacamp-website."
objects_df['Link'] = base_url + objects_df['Key']
# 将 DataFrame 写为 HTML
objects_df.to_html('report_listing.html',
columns=['Link', 'LastModified', 'Size'],
render_links=True)

将 HTML 文件上传到 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)Python 中的 AWS Boto 入门