Hello everyone,
I would appreciate it if you can help me of what is wrong in my code. I have a list of objects, specifically ArcGIS items. My code is basically:
import dask.bag as db
def get_attribute(i):
return i.title
bag = db.from_sequence(itms)
result = db.map(lambda x: get_attribute(x) , bag).compute()Then I am getting this error:
ValueError: too many values to unpack (expected 2)
I thought maybe dask bag does not work with sequences of objects. It might be only for sequences of literal values. But I tried the same code with objects based on a simple class called Point:
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def get_x(self):
return self.x
def get_y(self):
return self.y
######################
######################
def get_x(p):
return p.get_x()
p1 = Point(1,2)
p2 = Point(-3,-1)
p3 = Point(0,0)
pnts = [p1,p2,p3]
bag = db.from_sequence(pnts)
result = db.map(lambda x: get_x(x) , bag).compute()And it is working fine!!
So please let me know what I'am doing wrong.
Thank you so much.