将数据帧作为镶木地板文件直接发送到dropbox



在我的脚本中,我生成了一个数据帧,我想将其作为镶木地板文件直接上传到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

你知道否则怎么办吗?

调用fileToSave=tempDf.to_parquet('newFile.parquet')时,它会将表保存在名为newfile.parquet的本地文件中,并返回None

你想做的是:

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

这将把df转换成字节(在内存中(,然后可以上传到dropbox。

最新更新