合併 2 月的每日請求
距離 Sam 上次執行報表指令碼已經過了一個月,現在是時候為 2 月份產生新的報表了。
她想上傳 2 月份的新報表並更新檔案清單,延伸她在上一段影片課程中完成的工作:

她已建立 boto3 的 S3 用戶端並存到變數 s3。她也把物件的內容存到 request_files。
你將協助 Sam 從 gid-requests 儲存貯體下載 2 月份的檔案,並把它們串接成單一的 DataFrame!
本練習屬於課程
Python 中的 AWS Boto 入門
練習說明
- 從
s3載入每個物件。 - 讀入
pandas,並將其附加到df_list。 - 串接
df_list中所有的 DataFrame。 - 預覽這個 DataFrame。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
df_list = []
# Load each object from s3
for file in request_files:
s3_day_reqs = s3.____(Bucket='gid-requests',
Key=file['Key'])
# Read the DataFrame into pandas, append it to the list
day_reqs = pd.read_csv(s3_day_reqs['____'])
df_list.append(day_reqs)
# Concatenate all the DataFrames in the list
all_reqs = pd.____(df_list)
# Preview the DataFrame
all_reqs.head()