Comments (5)
Can you show the full Traceback? I am unable to reproduce the issue in practically the same environment. I sense some installation issue is causing this.
from geopandas.
Traceback (most recent call last):
File "/home/jovyan/mambaforge/envs/geopandas/lib/python3.12/site-packages/pandas/core/apply.py", line 314, in transform_str_or_callable
return obj.apply(func, args=args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jovyan/mambaforge/envs/geopandas/lib/python3.12/site-packages/geopandas/geoseries.py", line 673, in apply
result = super().apply(func, args=args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jovyan/mambaforge/envs/geopandas/lib/python3.12/site-packages/pandas/core/series.py", line 4904, in apply
).apply()
^^^^^^^
File "/home/jovyan/mambaforge/envs/geopandas/lib/python3.12/site-packages/pandas/core/apply.py", line 1427, in apply
return self.apply_standard()
^^^^^^^^^^^^^^^^^^^^^
File "/home/jovyan/mambaforge/envs/geopandas/lib/python3.12/site-packages/pandas/core/apply.py", line 1507, in apply_standard
mapped = obj._map_values(
^^^^^^^^^^^^^^^^
File "/home/jovyan/mambaforge/envs/geopandas/lib/python3.12/site-packages/pandas/core/base.py", line 919, in _map_values
return arr.map(mapper, na_action=na_action)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jovyan/mambaforge/envs/geopandas/lib/python3.12/site-packages/pandas/core/arrays/base.py", line 2319, in map
return map_array(self, mapper, na_action=na_action)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jovyan/mambaforge/envs/geopandas/lib/python3.12/site-packages/pandas/core/algorithms.py", line 1743, in map_array
return lib.map_infer(values, mapper, convert=convert)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "lib.pyx", line 2972, in pandas._libs.lib.map_infer
File "<stdin>", line 1, in <lambda>
TypeError: unsupported operand type(s) for +: 'Point' and 'int'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jovyan/mambaforge/envs/geopandas/lib/python3.12/site-packages/pandas/core/series.py", line 4766, in transform
result = SeriesApply(ser, func=func, args=args, kwargs=kwargs).transform()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jovyan/mambaforge/envs/geopandas/lib/python3.12/site-packages/pandas/core/apply.py", line 246, in transform
result = self.transform_str_or_callable(func)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jovyan/mambaforge/envs/geopandas/lib/python3.12/site-packages/pandas/core/apply.py", line 316, in transform_str_or_callable
return func(obj, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<stdin>", line 1, in <lambda>
File "/home/jovyan/mambaforge/envs/geopandas/lib/python3.12/site-packages/pandas/core/ops/common.py", line 76, in new_method
return method(self, other)
^^^^^^^^^^^^^^^^^^^
File "/home/jovyan/mambaforge/envs/geopandas/lib/python3.12/site-packages/pandas/core/arraylike.py", line 186, in __add__
return self._arith_method(other, operator.add)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jovyan/mambaforge/envs/geopandas/lib/python3.12/site-packages/pandas/core/series.py", line 6115, in _arith_method
return base.IndexOpsMixin._arith_method(self, other, op)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jovyan/mambaforge/envs/geopandas/lib/python3.12/site-packages/pandas/core/base.py", line 1382, in _arith_method
result = ops.arithmetic_op(lvalues, rvalues, op)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jovyan/mambaforge/envs/geopandas/lib/python3.12/site-packages/pandas/core/ops/array_ops.py", line 273, in arithmetic_op
res_values = op(left, right)
^^^^^^^^^^^^^^^
TypeError: unsupported operand type(s) for +: 'GeometryArray' and 'int'
from geopandas.
I have the same result installing geopandas in micromamba docker image:
docker run --rm -it mambaorg/micromamba bash
$ micromamba create -n geopandas -c conda-forge geopandas
$ micromamba activate geopandas
$ python
>>> import geopandas
>>> from shapely import Point, Polygon
>>> s = geopandas.GeoSeries([Point(0, 0)])
>>> s.transform(lambda x: x + 1)
...
TypeError: unsupported operand type(s) for +: 'Point' and 'int'
...
TypeError: unsupported operand type(s) for +: 'GeometryArray' and 'int'
>>> geopandas.show_versions()
SYSTEM INFO
-----------
python : 3.12.1 | packaged by conda-forge | (main, Dec 23 2023, 08:03:24) [GCC 12.3.0]
executable : /opt/conda/envs/geopandas/bin/python
machine : Linux-6.5.0-15-generic-x86_64-with-glibc2.36
GEOS, GDAL, PROJ INFO
---------------------
GEOS : 3.12.1
GEOS lib : None
GDAL : 3.8.3
GDAL data dir: /opt/conda/envs/geopandas/share/gdal
PROJ : 9.3.1
PROJ data dir: /opt/conda/envs/geopandas/share/proj
PYTHON DEPENDENCIES
-------------------
geopandas : 0.14.3
numpy : 1.26.4
pandas : 2.2.0
pyproj : 3.6.1
shapely : 2.0.2
fiona : 1.9.5
geoalchemy2: None
geopy : None
matplotlib : 3.8.2
mapclassify: 2.6.1
pygeos : None
pyogrio : None
psycopg2 : None
pyarrow : None
rtree : 1.2.0
from geopandas.
Thanks! I can reproduce in the container. That doesn't help me understanding why it happens but it is a step forward.
from geopandas.
I am stupid.
GeoSeries.transform
is a new method that is available only on geopandas main branch and will be released as part of GeoPandas 1.0 in about two months. Any older version of geopandas is falling back to pandas.Series.transform
, which obviously cannot handle geometries.
If you are installing released versions please refer to the stable documentation, which is what geopandas.org shows by default.
from geopandas.
Related Issues (20)
- BUG: assignment destination is read-only when assigning after applying ufunc HOT 8
- ENH: Allow to change schema and/or metadata in to_parquet HOT 4
- Support `orient` keyword in to_json HOT 3
- TST/COMPAT: Ignore int64 vs int_nativesize mismatches introduced by pandas 2.x HOT 2
- COMPAT: Default value of observed parameter in dissolve
- BUG: explore() using `cmap` instead of `color` attribute for *list-like of colors* when if `column` and `categorical` is set HOT 4
- ENH: parity between GeoDataFrame.to_json and GeoSeries.to_json HOT 1
- BUG: reducing shapely ufunc failing when called on a GeoSeries
- GeoPandas 1.0 release HOT 11
- MAINT: Fiona 1.10 support HOT 4
- BUG: up to 4 times slower in Linux compared to Windows when using gpd.read_file to read vector data HOT 6
- BUG: Is it possible to use GeoPandas on Windows 7 ?
- BUG: Unable to append to a layer when using fiona backend HOT 3
- BUG: plotting_with_geoplot example is broken HOT 1
- ENH: Add a Voronoi Diagram algorithm HOT 1
- BUG: The dissolve feature generates a new geometry HOT 4
- REGR: incorrect order of left sjoin with within predicate HOT 1
- BUG: wrong foxpro DBF file read HOT 7
- Fiona 1.10a2 issues HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geopandas.