Reputation: 881
I am using pyspark and I am having trouble writing to S3, but reading from S3 is not a problem.
this is my code:
dic = {'a': {'c1(%)': 0.0, 'c2': 0, 'c3($)': 260, 'c4(%)': 4.79, 'c5': 78, 'c6': 352}, 'b': {'c1(%)': 0.0, 'c2': 0, 'c3($)': 5, 'c4(%)': 0.09, 'c5': 2, 'c6': 280}, 'c': {'c1(%)': 0.0, 'c2': 0, 'c3($)': 0, 'c4(%)': 0.0, 'c5': 0, 'c6': 267}}
df = pd.DataFrame(dic)
df.to_csv("s3://work/.../filename_2018-01-04_08:50:45.csv")
this is the error:
IOError: [Errno 2] No such file or directory: 's3://work/.../filename_2018-01-04_08:50:45.csv'
what is the problem?
Upvotes: 1
Views: 13875
Reputation: 2696
See my comment above, you need to use a Spark DataFrame. One easy way to accomplish this would be to turn the index on the Pandas DF into a column and then convert to spark DF:
df2=sqlContext.createDataFrame(df.reset_index(drop=False))
Then use:
df2.write.save("s3://work/.../filename_2018-01-04_08:50:45.csv", format='csv', header=True)
Upvotes: 4