pandas Reading files into pandas DataFrame Collect google spreadsheet data into pandas dataframe


Sometimes we need to collect data from google spreadsheets. We can use gspread and oauth2client libraries to collect data from google spreadsheets. Here is a example to collect data:


from __future__ import print_function
import gspread
from oauth2client.client import SignedJwtAssertionCredentials
import pandas as pd
import json

scope = ['']

credentials = ServiceAccountCredentials.from_json_keyfile_name('your-authorization-file.json', scope)

gc = gspread.authorize(credentials)

work_sheet = gc.open_by_key("spreadsheet-key-here")
sheet = work_sheet.sheet1
data = pd.DataFrame(sheet.get_all_records())