Articles
(Computing fraction of long trips with %2525252525252560delayed%2525252525252560 functions)
Querying Python interpreter's memory usage

In Python, you can use the built-in psutil module to query the Python interpreter's memory usage. Here's an example:


Allocating memory for an array

In Python, you can allocate memory for an array using various built-in modules such as array, numpy or using simple list comprehension.


Allocating memory for a computation

In Python, memory allocation is handled automatically by the interpreter, and you typically don't need to manually allocate memory for a computation. However, you can optimize your code to minimize memory usage and improve performance.

Here are some tips to reduce memory usage durin
Querying array memory Usage

In Python, you can query the memory usage of an array using various built-in modules such as numpy or the sys mo
Querying DataFrame memory usage

To query the memory usage of a Pandas DataFrame in Python, you can use the memory_usage() method. This method returns the memory usage of each column of the DataFrame.


Using pd.read_csv() with chunksize

pd.read_csv() is a powerful method for reading CSV files into a Pandas DataFrame. However, it can be memory-intensive when wo
Examining a chunk

When using pd.read_csv() with the chunksize parameter, you can examine each chunk of data before processing it.
Filtering a chunk

When working with large files using pd.read_csv() with the chunksize parameter, it is often useful to filter the
Chunking & filtering together

Chunking and filtering can be used together to process large data sets efficiently while only retaining the relevant data in memory. This
Using pd.concat()

pd.concat() is a function in the Pandas library that allows you to concatenate Pandas objects along a particular axis, either
Plotting the filtered results

You can plot the filtered results of a Pandas DataFrame using the plot() method provided by Pandas. Here's an example:


Managing Data with Generators

Generators are a powerful tool for managing large datasets that may not fit into memory. Rather than loading the entire dataset into memor
Filtering in a list comprehension

Filtering in a list comprehension allows you to create a new list that contains only the elements from an original list that meet certain
Filtering & summing with generators


Aggregating with Generators

You can use a generator expression to compute aggregates on a large dataset without loading the entire dataset into memory at once. For example, you might use a generator expression to compute the sum of a column in a large CSV file.

Computing the fraction of long trips

Computing the fraction of long trips is a common task in data analysis, and it can be done efficiently in Python using generators. Here
Delaying Computation with Dask

Built-in Functions

Enjoyed this article? Share it!