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'])

# 建立一個「Link」欄,包含網站網址 + key
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 入門