30. Using masks to filter data, and perform search and replace, in NumPy and Pandas

In both NumPy and Pandas we can create masks to filter data. Masks are ’Boolean’ arrays – that is arrays of true and false values and provide a powerful and flexible method to selecting data.

NumPy

creating a mask

Let’s begin by creating an array of 4 rows of 10 columns of uniform random number between 0 and 100. Continue reading “30. Using masks to filter data, and perform search and replace, in NumPy and Pandas”

21. NumPy basics: building an array from lists, basic statistics, converting to booleans, referencing the array, and taking slices

Most commonly we will be loading files into NumPy arrays, but here we build an array from lists and perform some basics stats on the array.

The examples below construct and use a 2 dimensional array (which may be though of as ’rows and columns’). Later we will look at higher dimensional arrays.

Building an array from lists

We use the np.array function to build an array from existing lists. Here each list represents a row of a data table. Continue reading “21. NumPy basics: building an array from lists, basic statistics, converting to booleans, referencing the array, and taking slices”