mirror of
https://github.com/wassname/geopandas.git
synced 2026-09-11 12:10:59 +08:00
Move overloaded operators to GeoSeries
This commit is contained in:
@@ -390,27 +390,6 @@ class GeoPandasBase(object):
|
||||
index=self.index, crs=self.crs)
|
||||
|
||||
|
||||
#
|
||||
# Implement standard operators for GeoSeries
|
||||
#
|
||||
|
||||
def __xor__(self, other):
|
||||
"""Implement ^ operator as for builtin set type"""
|
||||
return self.symmetric_difference(other)
|
||||
|
||||
def __or__(self, other):
|
||||
"""Implement | operator as for builtin set type"""
|
||||
return self.union(other)
|
||||
|
||||
def __and__(self, other):
|
||||
"""Implement & operator as for builtin set type"""
|
||||
return self.intersection(other)
|
||||
|
||||
def __sub__(self, other):
|
||||
"""Implement - operator as for builtin set type"""
|
||||
return self.difference(other)
|
||||
|
||||
|
||||
def _array_input(arr):
|
||||
if isinstance(arr, (MultiPoint, MultiLineString, MultiPolygon)):
|
||||
# Prevent against improper length detection when input is a
|
||||
|
||||
@@ -241,3 +241,23 @@ class GeoSeries(GeoPandasBase, Series):
|
||||
result.__class__ = GeoSeries
|
||||
result.crs = crs
|
||||
return result
|
||||
|
||||
#
|
||||
# Implement standard operators for GeoSeries
|
||||
#
|
||||
|
||||
def __xor__(self, other):
|
||||
"""Implement ^ operator as for builtin set type"""
|
||||
return self.symmetric_difference(other)
|
||||
|
||||
def __or__(self, other):
|
||||
"""Implement | operator as for builtin set type"""
|
||||
return self.union(other)
|
||||
|
||||
def __and__(self, other):
|
||||
"""Implement & operator as for builtin set type"""
|
||||
return self.intersection(other)
|
||||
|
||||
def __sub__(self, other):
|
||||
"""Implement - operator as for builtin set type"""
|
||||
return self.difference(other)
|
||||
|
||||
Reference in New Issue
Block a user