Open HaojunCai opened 3 years ago
Hi Haojun,
Thanks for raising up this issue. Trackintel now does not provide the possibility to join the information of different data models as internal functions. For joining staypoint with location level information, I would recommend using:
stps.reset_index().merge(locs, left_on=["location_id", "user_id"], right_on=["id", "user_id"]).set_index("id"))
This line resets the index of the input staypoint, merge the two dataframes on location_id
/id
and user_id
, and sets back the id
column for the staypoint index.
We are now planning to include helper functions in trackintel to join staypoint + location and tripleg + trip. Thanks again for raising our awareness :).
@hong2223 Should we create an assignable issue for these helper functions where we collect what is needed and close this issue? (I would like to have a way to join location IDs to trips :-) )
For the returns
stp_cls
andloc_cls
ofgenerate_locations()
function, I would like the possibility to have the coordinates of clustered locations (loc_cls
) assigned to each stay point (stp_cls
), so that I could further extract mobility features on the basis ofstp_cls
data. It could be achieved bystp_cls = stp_cls.join(loc_cls, on="location_id", lsuffix='user_id')
and could be set by default False to avoid data redundancy.