From 172282e50139ca271a4c19c7eb26b766567adf75 Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Tue, 2 Jul 2013 21:38:07 -0400 Subject: [PATCH] Implement standard set operators ^ | & - --- geopandas/geoseries.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/geopandas/geoseries.py b/geopandas/geoseries.py index 41811a0..4d7207b 100644 --- a/geopandas/geoseries.py +++ b/geopandas/geoseries.py @@ -357,6 +357,34 @@ class GeoSeries(Series): else: return False + def __xor__(self, other): + """ + The ^ operator implements symmetric_difference() as it does + for the builtin set type. + """ + return self.symmetric_difference(other) + + def __or__(self, other): + """ + The | operator implements union() as it does + for the builtin set type. + """ + return self.union(other) + + def __and__(self, other): + """ + The & operator implements intersection() as it does + for the builtin set type. + """ + return self.intersection(other) + + def __sub__(self, other): + """ + The - operator implements difference() as it does + for the builtin set type. + """ + return self.difference(other) + # # Implement pandas methods #