我已经将Jupyter与Google表格链接了,并且已经找到了如何写入单元格并创建新的工作表的方法,但是我想将输出内容写入现有的工作表中。
import gspread
from oauth2client.service_account import ServiceAccountCredentials
from df2gspread import df2gspread as d2g
scope = ['https://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name('./Service-Credentials.json', scope)
gc = gspread.authorize(creds)
spreadsheet_key = '18Ui9S1ElE204uYQYknrQxWZTOi4eNxkExD2WjLMdc5M'
spreadsheet_name = "Weekly SBR"
def SaveDataToSheet(df_to_save, sheet_tab_to_save_to):
d2g.upload(df_to_save, spreadsheet_key, sheet_tab_to_save_to, credentials=creds, row_names=True)
import pandas as pd
import io
import sys
import os
import datetime
import numpy as np
import matplotlib.pyplot as plt
df = pd.read_csv('~/Desktop/mixreport_20180926.csv')
def clean_df(df):
df = df[(df['Percentage_Rate'] != '-')]
df = df[(df['Percentage_Rate']>0.8999) & (df['Percentage_Rate']<0.9990)]
df = df[(df['Date_Uploaded'] > '2015-12-31')]
df = df.drop_duplicates['ID']
return df
sh = gc.open_by_url('https://docs.google.com/spreadsheets/d/18Ui9S1ElE204uYQYknrQxWZTOi4eNxkExD2WjLMdc5M/edit#gid=417026338')
因此,我尝试使用函数的输出更新现有的工作表。此外,我试图写到特定的列。这可能吗?