Skip to content
Advertisement

TypeError: ‘GroupedData’ object is not iterable in pyspark dataframe

I have a Spark dataframe sdf with GPS points that looks like this:

JavaScript

Since the spark dataframe contains different GPS trajectories generated by different users on different days, I want to write a function that loops through this df and feeds the corresponding set of coordinates to the (OSRM) request per date and per user group and not all at once.

JavaScript

Unfortunately, running the code blow returns a TypeError: 'GroupedData' object is not iterable. What am I missing:

JavaScript

Advertisement

Answer

You can try aggregating the string after group by:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement