Preface
This textbook came out of a need to teach Python for Data Analytics at Queens University of Charlotte. The course is designed to be an introduction to Python for students who have no prior programming experience. The goal is to provide a solid foundation in Python programming, focusing on data analysis and visualization.
The Goal of this Textbook
The primary goal of this textbook is to equip students with the skills and knowledge needed to say something interesting about a dataset. By the end, students will be able to explore, analyze, and visualize data using Python. It introduces students to data manipulation techniques, statistical analysis, and data visualization libraries commonly used in the field of data analytics. While it introduces students to basic statistical concepts—such as skewness, kurtosis, correlation, t-tests, and ANOVA—it is not intended to be a comprehensive statistics textbook. Where I teach, we offer multiple statistics courses that will go in greater depth. These methods are presented in order to provide students with practical tools for analyzing data. This textbook is intended to teach the basics of programming in so far as it is used for data analytics.
Pandas vs Polars
Data analysis in Python is quickly reaching an inflection point. Since 2008, Pandas has been the dominant data analytics library for Python. Built on top of NumPy, it provides a powerful way to solve most data analysis problems. As datasets have grown larger and larger, Pandas can slow down significantly. Polars was developed to solve this problem. Built in Rust, Polars is designed to be fast and efficient, even with large datasets. It uses Apache Arrow as its memory model, which allows for zero-copy data access and efficient data processing. As a result, Polars can handle larger datasets and perform operations faster than Pandas in many cases. In addition, some (including the current author) find the Polars syntax to be more intuitive and expressive than Pandas.
Polars, however, is still relatively new. While it has made great strides in recent years, it does not yet have the same level of community support and ecosystem as Pandas. Some libraries and tools that work with Pandas may not yet be compatible with Polars. As a result, there may be some limitations when using Polars for certain tasks.
This textbook will present its content in both Pandas and Polars. The reader can toggle between the two libraries for each chapter that works with dataframes (chapters 6 onward). The Polars sections will indicate when and why Polars works differently than Pandas. The goal is to provide the reader with a solid foundation in both libraries, allowing them to choose the one that best fits their needs. As Polars continues to grow and mature, it is likely that it will become an increasingly important tool for data analysis in Python.