From 120c84c8ab053cd212be77846a38bfd9ad99f07b Mon Sep 17 00:00:00 2001 From: ThibTrip <40694343+ThibTrip@users.noreply.github.com> Date: Sat, 23 Feb 2019 20:40:57 +0100 Subject: [PATCH 1/2] the method _validate for the geo accessor example now checks presence of substring 'lat' and 'lon' in each column The previous code was incompatible with the following paragraph. ("Now users can access your methods using the ``geo`` namespace"...) --- doc/source/development/extending.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/source/development/extending.rst b/doc/source/development/extending.rst index e6928d9efde06..97610a4866f30 100644 --- a/doc/source/development/extending.rst +++ b/doc/source/development/extending.rst @@ -33,8 +33,10 @@ decorate a class, providing the name of attribute to add. The class's @staticmethod def _validate(obj): - if 'lat' not in obj.columns or 'lon' not in obj.columns: - raise AttributeError("Must have 'lat' and 'lon'.") + # verify each column name contains 'lat' or 'lon' + for col in obj.columns: + if 'lat' not in col and 'lon' not in col: + raise AttributeError("Must have 'lat' and 'lon'.") @property def center(self): From a7b602eb3df14675d6e5a488b666cbdfdd6af611 Mon Sep 17 00:00:00 2001 From: ThibTrip <40694343+ThibTrip@users.noreply.github.com> Date: Sat, 23 Feb 2019 21:46:29 +0100 Subject: [PATCH 2/2] updated issue with "lat" and "lon" in _validate for the geo accessor in extending.rst After reading a comment from TomAugspurger I realised "lon" and "lat" had just been switched with "longitude" and "latitude" in the following code block. So I used those names here as well. --- doc/source/development/extending.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/source/development/extending.rst b/doc/source/development/extending.rst index 97610a4866f30..9e5034f6d3db0 100644 --- a/doc/source/development/extending.rst +++ b/doc/source/development/extending.rst @@ -33,10 +33,9 @@ decorate a class, providing the name of attribute to add. The class's @staticmethod def _validate(obj): - # verify each column name contains 'lat' or 'lon' - for col in obj.columns: - if 'lat' not in col and 'lon' not in col: - raise AttributeError("Must have 'lat' and 'lon'.") + # verify there is a column latitude and a column longitude + if 'latitude' not in obj.columns or 'longitude' not in obj.columns: + raise AttributeError("Must have 'latitude' and 'longitude'.") @property def center(self):