def get_s3_df(): url = f's3://{BUCKET_NAME}/{stock_code}/past_data.csv' with smart_open.open(url, 'rb', transport_params=transport_params) as f: df = pd.read_csv(f,parse_dates=True,index_col=0) return df