不知你要的是?
好吧 python 最常用的資料分析 pandas 存到 Google Sheets
你應該隨便都可找到範例 dataframe to google spreadsheet
from google.oauth2.service_account import Credentials
import gspread
import pandas as pd
scope = ['https://www.googleapis.com/auth/spreadsheets']
creds = Credentials.from_service_account_file("gs_credentials.json", scopes=scope)
gs = gspread.authorize(creds)
sheet = gs.open_by_url('https://docs.google.com/spreadsheets/d/1saffdgkq9aducY/edit#gid=0')
worksheet = sheet.get_worksheet(0)
df = pd.read_csv('data.csv')
worksheet.update([df.columns.values.tolist()] + df.values.tolist())