1

在我的脚本中,我生成了一个数据框,我想将它作为镶木地板文件直接上传到 Dropbox。我设法找到了这样的解决方案:

https://gist.github.com/MaxHalford/f17994c77bb775fdd04c9cd925e0b279

这可以帮助我保存数据框。但是,我真的很想直接发送拼花文件。

对我来说似乎很直观的选项:

fileToSave=tempDf.to_parquet('newFile.parquet')
upload_file(dbx, file_location, fileToSave)

但它抛出

TypeError: expected str, bytes or os.PathLike object, not NoneType

知道如何以其他方式完成吗?

4

1 回答 1

0

When you call fileToSave=tempDf.to_parquet('newFile.parquet'), it saves the table in a local file called newfile.parquet and returns None

What you want to do instead is:

data = tempDf.to_parquet() #  bytes content of the parquet file
dbx.files_upload(
        f=data,
        path=path,
        mode=dropbox.files.WriteMode.overwrite
    )

This will convert the df into bytes (in memory) that you can then upload to dropbox.

于 2021-07-06T07:23:49.193 回答