From the course: Faster pandas

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Measuring memory

Measuring memory

From the course: Faster pandas

Start my 1-month free trial

Measuring memory

- [Narrator] Measuring memory in Python can be tricky. Searching for finding memory usage will lead you into a rabbit hole with terms like resident memory usage, virtual memory size, RSS, and others. Lucky for you, Pandas makes it easy to show how much memory does a dataframe consume. Let's have a look. So ipython, and then we import pandas as pd. And then we load the data. Df equals pd.read_CSV, and we're going to take the taxi data that we have. We can look at the data types of each column. Df.dtypes. And you can see that the vendorID is an integer. The times are strings. And the trip distance is a float. And the data frame has memory usage method that we can have a look. It looks like the vendorID, which is an integer, and the times, which are strings, take the same memory. This is due to the fact that an object in Python is a pointer. Let's use the deep parameter to memory usage. So memory usage, deep equal true. And now we can see the difference between the vendor ID and the…

Contents