我能够复制,并且对我有用:
import pandas as pd
from gcloud import storage
client = storage.Client()
bucket = client.get_bucket('source')
d = {'col1': [1,2],'col2': [3,None]}
df = pd.DataFrame(data=d)
bucket.blob('file').upload_from_string(df.to_csv(index=False,encoding='utf-8'),content_type='application/octet-stream')
文件内容为:
col1,col2
1,3.0
2,
或者您可以使用:
df.fillna(value=0,inplace=True)
bucket.blob('file').upload_from_string(df.to_csv(index=False,content_type='application/octet-stream')
输出文件将是:
col1,0.0
您的代码中包含以下部分:
content_type=''application/octet-stream'
这是语法错误
content_type =''应用程序/八位字节流''
本文链接:https://www.f2er.com/3145356.html