Chapter 3. Moving from pandas to Polars
There is a good chance that you already have experience with pandas. If you don’t, you can safely skip this chapter. If you do, we encourage you to read this chapter; it will make the rest of the book easier to follow.
In this chapter we want to make sure that your transition from pandas to Polars is as smooth as possible by highlighting the similarities and, more importantly, the differences between these two packages.
Ever since Polars took off, it has been compared to pandas. While the comparison is often in favour of Polars, not everybody is equally respectful about this. We cannot abide this. The reason is that data scientists actually owe pandas a lot. Without pandas, there would probably be no Polars. We even think it’s safe to say that without pandas, Python wouldn’t be such a popular language for working with data. We’ll focus on the similarities and differences of these two packages as objectively as possible.
In this chapter, you’ll learn:
-
What pandas and Polars have in common
-
How the syntax and output of both packages differ in appearance
-
Which pandas concepts you need to unlearn
-
How common operations are performed in both packages
We will focus on the user experience, rather than the underlying mechanics, and we won’t compare the performance of pandas and Polars in this chapter. The instructions to get any files you might need are in Chapter 2. We assume that you have the files in the data subdirectory.
Animals
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access