## How to change the name of a Python Series?

When data wrangling you might need to manipulate the name of a Pandas Series. You might need also to modify the name of one, some or all Series indexes. In this tutorial, we’ll learn to do exactly that. Rename Pandas Series We’ll first import Pandas into our Python development environment: Then we’ll create a sample …

## Pandas: split a Series into two or more columns in Python

In today’s quick tutorial we’ll learn how to split data located in a Dataframe column into one or more columns. Most probably you’ll be acquiring your data from an API, database, text or csv file. But in this example we’ll use a simple dataframe will build. Let’s look at the data: manager target 0 Johns;Tim …

## How to convert a Series to a Numpy array in Python?

In this very short tutorial today we’ll learn how you can turn a Pandas Series to a Numpy Array in Python. Step 1: Create a Pandas Series We’ll use a simple Series made of air temperature observations: Step 2: Series conversion to NumPy array We’ll go over two different methods: Using np.array() We are able …

## How to export a Python Dataframe column to a list?

This quick tutorial will cover the topic of writing a DataFrame column to a Python list. Consider the following code snippet: Here’s our DataFrame header: manager target 0 Debbie 32000 1 Daisy 45000 2 Dorothy 18000 3 Tim 20000 4 Debbie 32000 Using pd.DataFrame.tolist() to write column to a list Here’s the Python code you’ll …

## Numpy: use np.append() and np.insert() to add lists to ndarray

In this recipe we’ll learn how to add numeric lists into NumPy ndarrays. We’ll look into two cases: appending a Python list to the end an existing array (which oculd be either 1d / 2d or more). Insert a list into a specific position in the array Use np.append() to concatenate a list and an …

## Find and count Numpy array frequency of unique row and column values

This short recipe will guide us through identifying and counting unique values in a Numpy array (Ndarray) Creating our NumPy ndarrays We’ll first a couple of Numpy arrays for use to use in our examples. Using numpy.unique() to count Numpy unique array values Run the following code: We’ll get a new array showing the distinct …

## Python lists as new columns in Pandas

Our quick data wrangling recipe today covers the topic of adding Python lists to Pandas DataFrames as columns and rows. Creating the data We’ll start with a simple dataset that we’ll use throughout this tutorial examples. Go ahead and copy this code into your data analysis Python environment. Let’s also define a simple list for …

## Pandas: select multiple columns in a dataframe based on value / condition / index

In today’s recipe we’ll learn how you can subset a DataFrame by selecting multiple columns. Preparations We’ll first create a simple DataFrame that we’ll use throughout the recipe: Here’s our DataFrame quarter person area budget 0 1 Debbie North 43654 1 2 Kim South 35795 2 3 Dorothy West 20860 3 4 Tim Midwest 25390 …

## How to count unique values in a Pandas Groupby object?

Today’s Python data wrangling recipe is about counting number of non unique entries in a Pandas DataFrame groupby object. We’ll start by importing the Pandas library and then acquiring our dataset from a comma separated value file into a DataFrame. We’ll use the Pandas read_csv function: Let’s take a quick look at the DataFrame Header: …

## How to count missing values in Pandas?

In this recipe we’ll learn how to easily count missing values in Pandas DataFrames and Series. We’ll specifically look into two key cases: Count missing/null values in a DataFrame column (Series). Count missing values in a specific DataFrame row Create the Dataset Type this into your Python environment: Here’s our newly created Dataset: person budget …