【问题标题】:Pandas Dataframe upload to Sagemaker to S3 bucketPandas Dataframe 上传到 Sagemaker 到 S3 存储桶
【发布时间】:2019-04-08 07:15:58
【问题描述】:

我试图找到将我的数据框作为 csv 上传到 S3 的解决方案。我试过这个资源,但我可能会感到困惑。 upload data to S3 with sagemaker

import boto3
s3 =boto.resource('s3')
bucket = 'work'
key = 'test.csv'
doc = df.to_csv('test.csv')
s3.Bucket(bucket).put_object(Key= key, Body = doc)

我收到以下错误:

ParamValidationError: Parameter validation failed:
Invalid type for parameter Body, value: None, type: <type 'NoneType'>, valid 
types: <type 'str'>, <type 'bytearray'>, file-like object

我对 s3 和使用 Sagemaker 非常陌生。我觉得我所做的是完全错误的。

【问题讨论】:

    标签: amazon-s3 boto3 amazon-sagemaker


    【解决方案1】:

    试试 .upload_file(local_file)。

    import boto3
    s3 = boto3.Session().resource('s3')
    bucket = 'your-bucket'
    key = 'path-in-bucket/test.csv' # filepath in s3
    doc = df.to_csv('test.csv') # your local file
    
    s3.Bucket(bucket).Object(key).upload_file(doc)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-19
      • 2020-01-16
      • 2015-03-12
      • 1970-01-01
      • 2021-10-07
      • 1970-01-01
      • 2022-11-05
      • 2022-12-22
      相关资源
      最近更新 更多