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

from_polars? #225

Open
eutwt opened this issue Dec 21, 2022 · 3 comments
Open

from_polars? #225

eutwt opened this issue Dec 21, 2022 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@eutwt
Copy link

eutwt commented Dec 21, 2022

I feel like I'm missing something, I see from_pandas, but surely there's a way to start from a polars dataframe too right?

@markfairbanks
Copy link
Owner

Yep - it's there. It looks like I missed adding it to the documentation.

import tidypolars as tp
import polars as pl

polars_df = pl.DataFrame(dict(x = range(3), y = range(3)))

tidypolars_df = tp.from_polars(polars_df)

type(tidypolars_df)
tidypolars.tibble.Tibble

@markfairbanks markfairbanks added the documentation Improvements or additions to documentation label Dec 21, 2022
@eutwt
Copy link
Author

eutwt commented Dec 21, 2022

Another thing I think would be useful to document (assuming I haven't missed it) is the fact that tp.col('x') seems to give a polars expression (?) so that tp.col('x') has all the polars methods available (?). Took me a while to figure that out. For example, I just spent a good amount of time trying to figure out how to do the action below with tidypolars methods before realizing I could just use the polars methods. In retrospect it seems obvious it would work this way, but I'm sure there are others out there as slow as me :)

df.summarise(y = tp.col('y').str.concat(', '), by = tp.col('x').alias('x_group'))

@markfairbanks
Copy link
Owner

Yep, that's a good idea. I'll add that too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants