Using NumPy and Linear Algebra for Faster Python Code | Real Python Podcast #146

preview_player
Показать описание
Are you still using loops and lists to process your data in Python? Have you heard of a Python library with optimized data structures and built-in operations that can speed up your data science code? This week on the show, Jodie Burchell, developer advocate for data science at JetBrains, returns to share secrets for harnessing linear algebra and NumPy for your projects.

Jodie details how most people begin their data science journey using loops to iterate over values and apply operations sequentially. We talk about how loops are friendly for beginners, being clear to read and easy to debug, but unfortunately don't scale well, especially with large amounts of data.

Jodie shares some of the basics of linear algebra and how to organize data into vectors. We talk about how the NumPy library leverages those concepts to improve data processing. We discuss how the library includes operations for vector and matrix addition and subtraction, and why these operations are more efficient than loops. We also cover how NumPy stores arrays in memory and when working with them is faster vs when it's not.

Рекомендации по теме
Комментарии
Автор

Learning numpy was a bit of an awkward experience. It tries to replicate the matlab syntax, but the code is clunkier most of the time. Broadcasting arrays with 'newaxis' or ':' commands is confusing AF and I've defaulted to the einsum method for most matrix operations... Still, a great free tool to have.

OloNadTrolo