Step-by-Step Guide — Building a Prediction Model in Python
Understanding the Apple Stock Data

Secondly, we will start loading the data into a dataframe, it is a good practice to take a look at it before we start manipulating it. This helps us to understand that we have the right data and to get some insights about it.

As mentioned earlier, for this exercise we will be using historical data of Apple. I thought Apple would be a good one to go with. After walking through with me on this project, you will learn some skills that will give you the ability to practice yourself using different datasets.

The dataframe that we will be using contains the closing prices of Apple stock of the last one year (Sept 16, 2019 — Sept 15, 2020).

Read Data

import pandas as pd df = pd.read_csv('aapl_stock_1yr.csv')

Head Method

The first thing we’ll do to get some understanding of the data is using the head method. When you call the head method on the dataframe, it displays the first five rows of the dataframe. After running this method, we can also see that our data is sorted by the date index.

df.head()

image by author

Tail Method

Another helpful method we will call is the tail method. It displays the last five rows of the dataframe. Let’s say if you want to see the last seven rows, you can input the value 7 as an integer between the parentheses.

df.tail(7)

image by author

Now we have an idea of the data. Let’s move to the next step which is data manipulation and making it ready for prediction.
['Behic Guven']
['Machine Learning', 'Artificial Intelligence', 'Technology', 'Data Science', 'Programming']