I want to group the points by userid then create a LineString for each userid. Here's the GeoDataframe:
My goal is to store the results in a Geodataframe. Here's the code which I actually obtained from one question in this forum several years ago:
line_strings = df.groupby("userid")["geometry"].apply(lambda x: LineString(x.tolist()) if x.size > 1 else x.tolist())
However, the output is in Series instead.
So if I want to convert it back to GeoDataFrame, I unable to do so because it said TypeError: Input must be valid geometry objects: [<POINT (900800.126 7174374.539)>]
So I want to know where is my mistake?
P.S.: I also want to know how can I exclude User IDs that has only one point? (Hence LineString can't be created for these User IDs)

