2월 집계 보고서 업로드
이전 연습 문제에서 Sam은 원시 데이터 버킷에서 해당 월의 파일을 다운로드했어요.
그런 다음 한 달치의 모든 요청과 요청 유형을 보여주는 하나의 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 |
이미 boto3 S3 클라이언트를 변수 s3로 만들어 두었어요.
이달의 요청 통계를 게시할 수 있도록 도와주세요.
agg_df를 CSV와 HTML 파일로 저장한 뒤, S3에 공개 파일로 업로드하세요.
이 연습은 강의의 일부입니다
Python으로 시작하는 AWS Boto
연습 안내
agg_df의 CSV와 HTML 버전을 각각'feb_final_report.csv'와'feb_final_report.html'로 저장하세요.- 두 파일을
gid-reports버킷에 업로드하고, 공개 읽기 권한으로 설정하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# 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': '____',
'____': '____'})