Pandas apply to dateframe produces '<built-in method values of …'

后端 未结 2 974
被撕碎了的回忆
被撕碎了的回忆 2021-01-11 21:52

I\'m trying to build a GeoJSON object. My input is a csv with an address column, a lat column, and a lon column. I then created Shapely points out of the coordinates , buffe

相关标签:
2条回答
  • 2021-01-11 22:35

    I got to this post because I ran into a similar issue, but when running a PySpark DataFrame instead of Pandas.

    In case someone ends up here, like myself, I'll explain how I fixed it for a PySpark DataFrame.

    The reason why I was getting the error (built-in method of Row object, in my case), was because my field name count was colliding with the inherited method count from python tuples (as seen here).

    The solution was simply change the name of the field to something like my_count and it worked fine.

    0 讨论(0)
  • 2021-01-11 22:48

    Thanks, DSM, for pointing that out. Lesson learned: pandas is not good for arbitrary Python objects

    So this is what I wound up doing:

    temp = zip(list(data.geom), list(data.address))
    output = map(lambda x: {'geometry': x[0], 'properties':{'address':x[1]}}, temp)
    
    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题