datasheets is a library for interfacing with Google Sheets, including reading data from, writing data to, and modifying the formatting of Google Sheets. It is built on top of Google’s google-api-python-client and oauth2client libraries using the Google Drive v3 and Google Sheets v4 REST APIs.

It can be installed with pip via pip install datasheets.

Basic Usage

Get the necessary OAuth credentials from the Google Developer Console as described in Getting OAuth Credentials.

After that, using datasheets looks like:

import datasheets

# Create a data set to upload
import pandas as pd
df = pd.DataFrame([('a', 1.3), ('b', 2.7), ('c', 3.9)], columns=['letter', 'number'])

client = datasheets.Client()
workbook = client.create_workbook('my_new_workbook')
tab = workbook.create_tab('my_new_tab')

# Upload a data set
tab.insert_data(df, index=False)

# Fetch the data again
df_again = tab.fetch_data()

# Show workbooks you have access to; this may be slow if you are shared on many workbooks

# Show tabs within a given workbook

Indices and tables