上传 2 月份的汇总报告
在上一个练习中,Sam 从原始数据的存储桶下载了该月的文件。
随后她将这些文件合并为一个 DataFrame,展示该月的所有请求及其请求类型。
她把这个 DataFrame 存在变量 all_reqs 中,并使用 pandas 的 groupby 功能按服务名称统计请求次数,生成了新的 DataFrame agg_df:
| service_name | count | |
|---|---|---|
| 0 | 72 Hour Violation | 2910 |
| 1 | Chain Link Fence Repair | 90 |
| 2 | Collections Truck Spill | 30 |
| 3 | Container Left Out | 120 |
| 4 | Dead Animal | 360 |
她已经在变量 s3 中创建了 boto3 的 S3 客户端。
请帮助她发布本月的请求统计。
将 agg_df 写出为 CSV 和 HTML 文件,并将它们作为公共文件上传到 S3。
本练习是课程的一部分
Python 中的 AWS Boto 入门
练习说明
- 将
agg_df分别写出为 CSV 和 HTML,文件名为'feb_final_report.csv'和'feb_final_report.html'。 - 将两个版本的
agg_df上传到gid-reports存储桶,并设置为 public read。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Write agg_df to a CSV and HTML file with no border
agg_df.____('./____')
agg_df.____('./____', border=0)
# Upload the generated CSV to the gid-reports bucket
s3.____(Filename='./feb_final_report.csv',
Key='2019/feb/final_report.html', Bucket='gid-reports',
____ = {'ACL': '____'})
# Upload the generated HTML to the gid-reports bucket
s3.upload_file(Filename='./feb_final_report.html',
Key='2019/feb/final_report.html', Bucket='gid-reports',
____ = {'ContentType': '____',
'____': '____'})