Skip to main content
Colin Jaffe/2 min read

Visualizing Apple Stock Trends with Pyplot: Identifying Highs and Lows

EDA (Exploratory Data Analysis)

1

Inspect Shape & Types

df.info(), df.describe() — get the lay of the land.

2

Check for Missing Values

df.isnull().sum() — strategies depend on amount and pattern.

3

Visualize Distributions

Histograms, boxplots — outliers and skew matter.

4

Look for Relationships

Correlation matrix, pairplots — spot signal early.

Master Data Science at Noble Desktop

Noble Desktop's Data Science & AI Certificate covers Python, machine learning, and the modern data science stack.

This lesson is a preview from our Data Science & AI Certificate Online (includes software) and Python Certification Online (includes software & exam). Enroll in a course for detailed lessons, live instructor support, and project-based training.

Plot Apple's highest and lowest prices using pyplot's scatterplot method. Watch this tutorial to learn the key concepts and techniques.

Let's plot some data. First, I'm going to include the low, so I'm going to add that here as well. We'll get rid of the print statements—we don't really need those.

Let's find the lowest price in the data frame. That will be lowest_apple_price = apple_prices["3. low"].min(). It's very similar to before, just the reverse. This gives us the lowest of the low prices.

Then let's find the row with that price: low_date = apple_prices[apple_prices["3. low"] == lowest_apple_price].

And finally, let's actually get the date from that. low_date = low_date.index[0]. Let's run that block again.

Now that we're graphing, let's just see. I don’t have quite everything here, but if I run this, it’s going to make a big old pyplot figure using the BMH style. We plot the dates as the X values against the closing prices as the Y values. Then we use pyplot.show() to display the graph. And here it is.

Here are Apple’s lowest prices in the early 2000s, and then rising, rising, rising. All right, so that's how we can do some good work with this data. Now, I’d like to give you folks an extra challenge.

Use pyplot.scatter() to add the high and the low to the graph. You can kind of eyeball the high—it looks like it's this special day here in 2012—but it's not entirely clear where the low is.

Probably somewhere in here. I mean, we can look at the date—we can print out the date.

We've got these variables: low_date and lowest_apple_price, high_price and high_date. We want to take those two X and Y coordinates and plot them using pyplot.scatter(). That’s our next challenge.

And I'll let you folks do that, and we'll talk about how we do it in the next video. Take a moment and see if you can figure it out on your own.