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

旧城冷巷雨未停 提交于 2019-12-01 03:36:45

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)

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!