Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package
name: Build and Test

on: push

Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,4 @@ ENV/

/tests/tests.config
/tests/creds.json
/travis.secrets.tar.gz
/.venv
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ recursive-include tests *.example
recursive-include tests *.json
recursive-include tests *.py
exclude tests/creds.json
exclude tests/tests.config
7 changes: 4 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ gspread-dataframe
.. image:: https://badge.fury.io/py/gspread-dataframe.svg
:target: https://badge.fury.io/py/gspread-dataframe

.. image:: https://app.travis-ci.com/robin900/gspread-dataframe.svg?branch=master
:target: https://travis-ci.com/robin900/gspread-dataframe
.. image:: https://github.com/robin900/gspread-dataframe/actions/workflows/python-package.yml/badge.svg?branch=master
:target: https://github.com/robin900/gspread-dataframe/actions/workflows/python-package.yml

.. image:: https://img.shields.io/pypi/dm/gspread-dataframe.svg
:target: https://pypi.org/project/gspread-dataframe
Expand Down Expand Up @@ -72,7 +72,8 @@ Installation
Requirements
~~~~~~~~~~~~

* Python 2.7, 3+
* Python 3 only, for releases 4.0.0 and later
* Python 2.7 and 3 for releases prior to 4.0.0
* gspread (>=3.0.0; to use older versions of gspread, use gspread-dataframe releases of 2.1.1 or earlier)
* Pandas >= 0.24.0

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.0
4.0.0b1
5 changes: 1 addition & 4 deletions gspread_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import logging
import re
from numbers import Real
from six import string_types, ensure_text

try:
from collections.abc import defaultdict
Expand Down Expand Up @@ -70,11 +69,9 @@ def _cellrepr(value, allow_formulas, string_escaping):
return ""
if isinstance(value, Real):
return value
if not isinstance(value, string_types):
if not isinstance(value, str):
value = str(value)

value = ensure_text(value, encoding='utf-8')

if (not allow_formulas) and value.startswith("="):
return "'%s" % value
else:
Expand Down
62 changes: 62 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "gspread-dataframe"
dynamic = ["version"]
description = "Read/write gspread worksheets using pandas DataFrames"
readme = "README.rst"
requires-python = ">=3.0"
license = { file = "LICENSE" }
keywords = ['spreadsheets', 'google-spreadsheets', 'pandas', 'dataframe']
authors = [{ name = "Robin Thomas", email = "[email protected]" }]
maintainers = [{ name = "Robin Thomas", email = "[email protected]" }]

classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Topic :: Office/Business :: Financial :: Spreadsheet",
"Topic :: Software Development :: Libraries :: Python Modules",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3"
]

dependencies = ["gspread>=3.0.0", "pandas>=0.24.0"]

[project.optional-dependencies]
dev = [
"gitchangelog",
"Sphinx",
"Sphinx-PyPI-upload3",
"twine",
"pytest",
"oauth2client"
]

test = [
"pytest",
"oauth2client",
"pandas",
"tox"
]

[project.urls]
"Homepage" = "https://github.com/robin900/gspread-dataframe"
"Bug Reports" = "https://github.com/robin900/gspread-dataframe/issues"
"Source" = "https://github.com/robin900/gspread-dataframe/"

[tool.setuptools.dynamic]
version = {file = "VERSION"}

[tool.coverage.report]
fail_under = 90
show_missing = true
exclude_lines = [
'pragma: no cover',
'\.\.\.',
'if TYPE_CHECKING:',
"if __name__ == '__main__':",
]

6 changes: 0 additions & 6 deletions requirements-dev.txt

This file was deleted.

15 changes: 0 additions & 15 deletions setup.cfg

This file was deleted.

52 changes: 0 additions & 52 deletions setup.py

This file was deleted.

14 changes: 10 additions & 4 deletions tests/gspread_dataframe_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@ def test_skiprows(self):
self.assertEqual(len(df), 6)

def test_squeeze(self):
df = get_as_dataframe(self.sheet, usecols=[0], squeeze=True)
self.assertTrue(isinstance(df, pd.Series))
self.assertEqual(len(df), 9)
if pd.__version__ < '2.0.0':
df = get_as_dataframe(self.sheet, usecols=[0], squeeze=True)
self.assertTrue(isinstance(df, pd.Series))
self.assertEqual(len(df), 9)

def test_converters_datetime(self):
df = get_as_dataframe(
Expand Down Expand Up @@ -218,7 +219,7 @@ def test_parse_dates_custom_parser(self):
df = get_as_dataframe(
self.sheet,
parse_dates=[4],
date_parser=lambda x: datetime.strptime(x, "%Y-%m-%d") if x is not np.nan else None
date_format="%Y-%m-%d"
)
self.assertEqual(df["Date Column"][0], datetime(2017, 3, 4))

Expand Down Expand Up @@ -289,6 +290,11 @@ def test_write_basic(self):
CELL_LIST_STRINGIFIED, value_input_option="USER_ENTERED"
)

def test_write_empty_df_no_updates(self):
df = pd.DataFrame.from_records([])
set_with_dataframe(self.sheet, df)
self.sheet.update_cells.assert_not_called()

def test_include_index_false(self):
df = get_as_dataframe(self.sheet, na_filter=False)
df_index = df.set_index("Thingy")
Expand Down
25 changes: 25 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[tox]
env_list =
3.8
3.13
minversion = 4.24.2

[testenv]
description = run the tests with pytest
package = wheel
wheel_build_env = .pkg
deps =
pytest>=6
coverage
oauth2client
!3.8: pandas>=2.0.0
3.8: pandas<2.0.0
commands =
coverage erase
coverage run -m pytest {tty:--color=yes} tests/gspread_dataframe_test.py tests/gspread_dataframe_integration.py {posargs}
coverage report --omit='tests/*'

[gh-actions]
python =
3.8: py38
3.13: py313
Binary file removed travis.secrets.tar.gz.enc
Binary file not shown.