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)

Expanding arrays


The concatenate function allows binding arrays together along a common axis, using the syntax seen on the screen. This approach requires that the arrays have similar shapes along the axes not used for binding. The result is a brand new ndarray that is the product of this gluing of arrays together. Other similar functions exist for this purpose, such as stack. We will not cover all of them.

Let's suppose that we want to add more rows to arr2. Use the following code to do this:

We create a brand new array. We don't need to use the copy method in this situation. This is the result:

We have added a fourth row to this array, binding a new array with the data (names in the array). It is still a two-dimensional array. For example, see the array in the following example. You can clearly see this is two-dimensional but has a single column, whereas the previous one has a single row, and this is the result when we add in this new column:

We will continue with mathematical operations with...