Book Image

Hands-On Data Analysis with NumPy and Pandas

By : Curtis Miller
5 (1)
Book Image

Hands-On Data Analysis with NumPy and Pandas

5 (1)
By: Curtis Miller

Overview of this book

Python, a multi-paradigm programming language, has become the language of choice for data scientists for visualization, data analysis, and machine learning. Hands-On Data Analysis with NumPy and Pandas starts by guiding you in setting up the right environment for data analysis with Python, along with helping you install the correct Python distribution. In addition to this, you will work with the Jupyter notebook and set up a database. Once you have covered Jupyter, you will dig deep into Python’s NumPy package, a powerful extension with advanced mathematical functions. You will then move on to creating NumPy arrays and employing different array methods and functions. You will explore Python’s pandas extension which will help you get to grips with data mining and learn to subset your data. Last but not the least you will grasp how to manage your datasets by sorting and ranking them. By the end of this book, you will have learned to index and group your data for sophisticated data analysis and manipulation.
Table of Contents (12 chapters)

Creating NumPy arrays


Now that we have discussed NumPy data types and have been briefly introduced to NumPy arrays, let's talk about how we can create NumPy arrays. In this section, we will create NumPy arrays using various functions. There are functions that create what are known as empty ndarray; functions for creating ndarray filled with 0s, 1s, or random numbers; and functions for creating ndarray using data. We will discuss all of these, along with saving and loading NumPy arrays from disk. There are a few ways to create arrays. One way is to use the array function, where we give an iterable object or a list of iterable objects, from which an array will be generated.

We will do this using lists of lists, but these could be lists of tuples, tuples of tuples, or even other arrays. There are ways to automatically create arrays filled with data as well. For example, we can use functions such as ones, zeros, or randn; the latter is filled with randomly generated data. These arrays require...