Save Dataframe to csv directly to s3 Python
Question: I have a pandas DataFrame that I want to upload to a new CVS file. The problem
is that I don't want to save the file locally before transferring it to s3. Is
there a method like to_csv for writing the dataframe to s3 directly? I am
using boto3.  
Here is what I have so far:

    
    
    import boto3
    s3 = boto3.client('s3', aws_access_key_id='key', aws_secret_access_key='secret_key')
    read_file = s3.get_object(Bucket, Key)
    df = pd.read_csv(read_file['Body'])
    
    # Make alterations to DataFrame
    
    # Then export DataFrame to CSV through direct transfer to s3
    


Answer: If you pass `None` as the first argument to
[`to_csv()`](http://pandas.pydata.org/pandas-
docs/stable/generated/pandas.DataFrame.to_csv.html) the data will be returned
as a string. From there it's an easy step to upload that to S3 in one go.

It should also be possible to pass a `StringIO` object to `to_csv()`, but
using a string will be easier.

