Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Returns of generate_locations() function #251

Open
HaojunCai opened this issue Jun 16, 2021 · 2 comments
Open

ENH: Returns of generate_locations() function #251

HaojunCai opened this issue Jun 16, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@HaojunCai
Copy link

For the returns stp_cls and loc_cls of generate_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 of stp_cls data. It could be achieved by stp_cls = stp_cls.join(loc_cls, on="location_id", lsuffix='user_id') and could be set by default False to avoid data redundancy.

@henrymartin1 henrymartin1 added the enhancement New feature or request label Jun 16, 2021
@hongyeehh hongyeehh self-assigned this Jun 30, 2021
@hongyeehh
Copy link
Member

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 :).

@henrymartin1
Copy link
Member

@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 :-) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants