【问题标题】:Python and using data from Google SheetsPython 和使用来自 Google 表格的数据
【发布时间】:2020-09-21 00:51:01
【问题描述】:

我想知道分析从 Google 表格中提取的数据的最佳方法是什么。我已成功连接到特定工作表并使用以下方法返回所有数据:

scope = ['https://spreadsheets.google.com/feeds','https://www.googleapis.com/auth/drive']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
client = gspread.authorize(creds)

sheet = client.open('KB Swings').sheet1


total_swings = sheet.get_all_records()
print(total_swings)

但我想对特定列中的数据进行基本求和。

【问题讨论】:

  • 电子表格擅长做求和...你甚至需要 Python 吗?
  • 然后我在其他地方使用结果。

标签: python google-sheets


【解决方案1】:

在 python 中分析表格数据的最佳方法是 pandas: Here is a short introduction.

【讨论】:

    【解决方案2】:

    我相信这是您想要的,但您是否考虑过在电子表格中计算总和?

        #get column values in column n
        col_vals = sheet.col_values(n)
        # sum of list
        col_sum = sum(col_vals)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多