Skip to main content

gspread-dataframe

https://badge.fury.io/py/gspread-dataframe.svg https://app.travis-ci.com/robin900/gspread-dataframe.svg?branch=master https://img.shields.io/pypi/dm/gspread-dataframe.svg Documentation Status

This package allows easy data flow between a worksheet in a Google spreadsheet and a Pandas DataFrame. Any worksheet you can obtain using the gspread package can be retrieved as a DataFrame with get_as_dataframe; DataFrame objects can be written to a worksheet using set_with_dataframe:

import pandas as pd
from gspread_dataframe import get_as_dataframe, set_with_dataframe

worksheet = some_worksheet_obtained_from_gspread_client

df = pd.DataFrame.from_records([{'a': i, 'b': i * 2} for i in range(100)])
set_with_dataframe(worksheet, df)

df2 = get_as_dataframe(worksheet)

The get_as_dataframe function supports the keyword arguments that are supported by your Pandas version’s text parsing readers, such as pandas.read_csv. Consult your Pandas documentation for a full list of options. Since the 'python' engine in Pandas is used for parsing, only options supported by that engine are acceptable:

import pandas as pd
from gspread_dataframe import get_as_dataframe

worksheet = some_worksheet_obtained_from_gspread_client

df = get_as_dataframe(worksheet, parse_dates=True, usecols=[0,2], skiprows=1, header=None)

New in version 4.0.0: drop_empty_rows and drop_empty_columns parameters, both True by default, are now accepted by get_as_dataframe. If you created a Google sheet with the default number of columns and rows (20 columns, 1000 rows), but have meaningful values for the DataFrame only in the top left corner of the worksheet, these parameters will cause any empty rows or columns to be discarded automatically.

Formatting Google worksheets for DataFrames

If you install the gspread-formatting package, you can additionally format a Google worksheet to suit the DataFrame data you’ve just written. See the package documentation for details, but here’s a short example using the default formatter:

import pandas as pd
from gspread_dataframe import get_as_dataframe, set_with_dataframe
from gspread_formatting.dataframe import format_with_dataframe

worksheet = some_worksheet_obtained_from_gspread_client

df = pd.DataFrame.from_records([{'a': i, 'b': i * 2} for i in range(100)])
set_with_dataframe(worksheet, df)
format_with_dataframe(worksheet, df, include_column_header=True)

Installation

Requirements

  • Python 2.7, 3+

  • gspread (>=3.0.0; to use older versions of gspread, use gspread-dataframe releases of 2.1.1 or earlier)

  • Pandas >= 0.24.0

From PyPI

pip install gspread-dataframe

From GitHub

git clone https://github.com/robin900/gspread-dataframe.git
cd gspread-dataframe
python setup.py install

Release files for gspread-dataframe 4.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gspread-dataframe 4.0.0
File Size Uploaded
gspread-dataframe-4.0.0.tar.gz 27.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gspread-dataframe 4.0.0
File Interpreter ABI Platform
gspread_dataframe-4.0.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 36.4 kB

Release files / gspread-dataframe-4.0.0.tar.gz

Download URL gspread-dataframe-4.0.0.tar.gz
Size 27.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5ca5493478ecae49b833664a06bac8e17b5b4ed0bdf77f551c948f30545860e6
BLAKE2b-256 checksum
How to use checksums
b4bc82a1a8a850468b5db7f894f2f73f690a927a5bf59a67581317c00c0a86d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / gspread_dataframe-4.0.0-py2.py3-none-any.whl

Download URL gspread_dataframe-4.0.0-py2.py3-none-any.whl
Size 9.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
19a3c6cd95bf85f8d6c3657227bb921ef36110174d365cc576defe4ed45b6f7d
BLAKE2b-256 checksum
How to use checksums
c92fffb71b19208cf3d3e1e1323716de07bdb46e24c850f2c5627cb8157d9687
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release history Release notifications | RSS feed

This release

4.0.0 This release

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.2

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.3

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.8

2 release files

3.0.7

2 release files

3.0.6

2 release files

3.0.5

2 release files

3.0.4

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page