温馨提示:本文翻译自stackoverflow.com,查看原文请点击:python 3.x - how to set path of bucket in amazonsagemaker jupyter notebook?

python 3.x - 如何在amazonsagemaker jupyter笔记本中设置存储桶的路径?

发布于 2020-03-27 11:47:21

我是AWS的新手,如何设置存储桶的路径并访问该存储桶的文件?

我需要用前缀更改什么吗?

import os
import boto3
import re
import copy
import time
from time import gmtime, strftime
from sagemaker import get_execution_role

role = get_execution_role()

region = boto3.Session().region_name

bucket='ltfs1' # Replace with your s3 bucket name
prefix = 'sagemaker/ltfs1' # Used as part of the path in the bucket where you store data
# bucket_path = 'https://s3-{}.amazonaws.com/{}'.format(region,bucket) # The URL to access the bucket

我正在使用上面的代码,但显示文件未找到错误

查看更多

查看更多

提问者
Scott
被浏览
50
ketcham 2019-07-03 23:14

如果您要访问的文件位于s3存储桶的根目录中,则可以按以下方式访问文件:

import pandas as pd

bucket='ltfs1'
data_key = 'data.csv'
data_location = 's3://{}/{}'.format(bucket, data_key)
training_data = pd.read_csv(data_location)

发布
问题

分享
好友

手机
浏览

扫码手机浏览