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# 2019/ で始まる gid-reports バケットのオブジェクトを一覧 r = s3.list_objects(Bucket='gid-reports', Prefix='2019/')# レスポンス内容をDataFrameへ変換 objects_df = pd.DataFrame(r['Contents'])

# Webサイト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 入門