Please help me in this issue?
split is a function. you should always use ( ) for functions. you have used [ ] in your code. [ ] is used in python collections to fetch elements. You can try running the program again.
Thanks Sunil for your response. This is what you asked me to change right? I got the same issue.
Please suggest me if I haven’t done correctly.
As you are slicing using [0:10] you should return list from the function. currently you are returning itertool grouper object and slicing it which is wrong. Return List(orderItemsPerOrderId)
Below code worked for me -
orderItemsMap = it.imap(lambda oi: (int(oi.split(",")), float(oi.split(","))),orderItems)
ordeItemsPerOrderId = it.groupby(sorted(orderItemsMap), lambda k:k)
return list (ordeItemsPerOrderId)
@Sunil_Itversity - You are using map not iter tools imap. The code that @jeevan_kishore trying is with itertool imap
map is a collection that you can loop over but not imap which is an itertool grouper object
Thanks both of you for your quick reply. It worked for me