## Dunder Data Challenge #5 Solution

Nov 25, 2019 This post presents a solution to Dunder Data Challenge #5 — Keeping Values Within the Interquartile Range.

All challenges may be worked in a Jupyter Notebook right now thanks to Binder (mybinder.org).

### Solution

We begin by finding the first and third quartiles of each stock using the `quantile` method. This is an aggregation which returns a single value for each column by default. Set the first parameter, `q` to a float between 0 and 1 to...

## The Craziness of Subset Selection in Pandas

Nov 21, 2019

Selecting subsets of data in pandas is not a trivial task as there are numerous ways to do the same thing. Different pandas users select data in different ways, so these options can be overwhelming. I wrote a long frou-part series on it to clarify how its done. For instance, take a look at the following options for selecting a single column of data (assuming it’s the first column):

• `df[‘colname’]`
• `df[[‘colname’]]`
• `df.colname`
• `df.loc[:,...`

## Dunder Data Challenge #5 — Keeping Values Within the Interquartile Range

Nov 14, 2019 In this challenge, you are given a table of closing stock prices for 10 different stocks with data going back as far as 1999. For each stock, calculate the interquartile range (IQR). Return a DataFrame that satisfies the following conditions:

• Keep values as they are if they are within the IQR
• For values lower than the first quartile, make them equal equal to the exact value of the first quartile
• For values higher than the third quartile, make them equal equal to the exact value of the...

## Dunder Data Challenge #4 - Solution

Nov 13, 2019 In this post, I detail the solution to Dunder Data Challenge #4 — Finding the Date of the Largest Percentage Stock Price Drop.

#### Solution

To begin, we need to find the percentage drop for each stock for each day. pandas has a built-in method for this called `pct_change`. By default, it finds the percentage change between the current value and the one immediately above it. Like most DataFrame methods, it treats each column independently from the others.

If we call it on our current...

## Dunder Data Challenge #4 - Finding the Date of the Largest Percentage Stock Price Drop

Nov 12, 2019

In this challenge, you are given a table of closing stock prices for 10 different stocks with data going back as far as 1999. For each stock, find the date where it had its largest one-day percentage loss.

## #### Begin working this challenge now in a Jupyter Notebook with Binder

Begin working this challenge now in a Jupyter Notebook thanks to Binder (mybinder.org). The data is found in the `stocks10.csv` file with the ticker symbol as a column name. The Dunder Data Challenges Github...

## Finding the Percentage of Missing Values in a Pandas DataFrame

Uncategorized Nov 01, 2019

In this tutorial, we will cover an efficient and straightforward method for finding the percentage of missing values in a Pandas DataFrame. This tutorial is available as a video on YouTube.

### Begin Mastering Data Science Now for Free!

Take my free Intro to Pandas course to begin your journey mastering data analysis with Python.

### Non-intuitive Solution

The final solution to this problem is not quite intuitive for most people when they first encounter it. We will slowly build up to it...

## Animating NBA Games with matplotlib and pandas

Uncategorized Oct 01, 2019

In this tutorial, game 7 of the 2016 NBA finals will be animated with Matplotlib one shot at a time within a Jupyter Notebook. This tutorial integrates many different topics including:

• Using the developer tools of a browser to discover non-public APIs
• Using h3theh3 requests library to get data into a Pandas DataFrame
• Creating a static visual representation of an NBA court with shots from a game using Matplotlib
• Creating a Matplotlib animation showing the description, score, time...

## Dunder Data Challenge #3 - Optimal Solution

Sep 17, 2019

In this article, I will present an ‘optimal’ solution to Dunder Data Challenge #3. Please refer to that article for the problem setup. Work on this challenge directly in a Jupyter Notebook right now by clicking this link.

### Naive Solution — Custom function with apply

The naive solution was presented in detail in the previous article. The end result was a massive custom function containing many boolean filters used to find specific subsets of data to...

## Use the brackets to select a single pandas DataFrame column and not dot notation

Sep 13, 2019

pandas offers its users two choices to select a single column of data and that is with either brackets or dot notation. In this article, I suggest using the brackets and not dot notation for the following ten reasons.

1. Select column names with spaces
2. Select column names that have the same name as methods
3. Select columns with variables
4. Select non-string columns
5. Set new columns
6. Select multiple columns
7. Dot notation is a strict subset of the brackets
8. Use one way which works for all situations
9. ...

## Dunder Data Challenge #3 - Naive Solution

Sep 12, 2019

To view the problem setup, go to the Dunder Data Challenge #3 post. This post will contain the solution.

### Master Data Analysis with Python

Master Data Analysis with Python is an extremely comprehensive course that will help you learn pandas to do data analysis.

I believe that it is the best possible resource available for learning how to data analysis with pandas and provide a 30-day 100% money back guarantee if you are not satisfied.

#### Solution

I will first present a naive solution that...