Giter VIP home page Giter VIP logo

Comments (5)

martinfleis avatar martinfleis commented on June 12, 2024

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.

floriandeboissieu avatar floriandeboissieu commented on June 12, 2024
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.

floriandeboissieu avatar floriandeboissieu commented on June 12, 2024

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.

martinfleis avatar martinfleis commented on June 12, 2024

Thanks! I can reproduce in the container. That doesn't help me understanding why it happens but it is a step forward.

from geopandas.

martinfleis avatar martinfleis commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.