Published on: 13th September 2022
How do third-party libraries work with Polars?
This post was created while writing my Up & Running with Polars course. Check it out here with a free preview of the first chapters
One thing people ask me about switching from Pandas to Polars is working with 3rd party libraries. What if they don’t support Polars?
Often, however, this isn’t much of an issue…
Take the example below with the NLP library Spacy. Here Spacy takes a column from a Polars dataframe in the same way it would take a column from a Pandas dataframe.
1 2 3 4 5 import spacy nlp = spacy.load("en_core_web_sm") doc = nlp(df[0,"text"]) spacy.displacy.render(doc, style="ent")
Why does this work so smoothly? Because many libraries aren’t looking for a pandas dataframe column - they just want an iterable. A pandas column is an iterable, but so is a tuple, list or a polars dataframe column.
Want to know more about Polars for high performance data science and ML? Then you can:
- check out my Polars course on Udemy
- follow me on twitter
- connect with me at linkedin
- check out my youtube videos
or let me know if you would like a Polars workshop for your organisation.