Tech Stock Prices
  • AI Chat
  • Code
  • Report
  • Beta
    Spinner

    Tech Stock Prices

    This dataset consists of the daily stock prices and volume of ten different tech companies: Apple (AAPL), Amazon (AMZN), Alibaba (BABA), Salesforce (CRM), Facebook (FB), Alphabet (GOOG), Intel (INTC), Microsoft (MSFT), Nvidia (NVDA), and Tesla (TSLA).

    There are ten CSV files in the data/ folder named with the stock symbol for each of the ten companies listed above. Looking for another company? You can download it from Yahoo Finance and upload it to your workspace.

    Not sure where to begin? Scroll to the bottom to find challenges!

    My goal here is to explore the returns and volatilities of the ten stocks provided, and make several comparisons between them, such as :

    • their Stock Value Evolution over the last twelve years
    • their Stock Value Evolution over the last six years
    • the mean, the maximum and the mininum Stock Value Evolution as well as their Volume of shares Traded each day

    We can assert that a dashboard using Power BI or Google Data Studio would be more convenient, in order to look at the data in an easier way. First we must import the data and explore it. Then we are going to clean it and create a few columns in order to make a clear analysis for the business team.

    To begin with, we import one dataset and take a look at it. The first dataframe here is about the Apple Company.

    import pandas as pd
    df_AAPL=pd.read_csv("data/AAPL.csv")
    print(df_AAPL.head())
    print(df_AAPL.info())

    It looks like there is no missing values and all the data have the right datatype, except for the "Date" column that should be a "datetime" object for a good Time Series Analysis. But first we must import the other csv files and also take a look at them.

    After importing the rest of the data, I did the same check for the other csv files. The main informations I retrieved are :

    • The majority of the files have 2999 non-null entries, each one of them corresponds to an unique day with the same values ('Open','High','Low','Close','Adj Close' and 'Volume')
    • The first date present in the data is '2010-01-04' and the last one is '2021-05-10'
    • Some files have less data, for example the Tesla file, which has 2876 non-null entries; The Facebook file, which has 2399 non-null entries; and the Alibaba one, which has 1812 non-null entries. It can be explain because their datasets start at dates later than the others.
    df_AMZN=pd.read_csv("data/AMZN.csv")
    df_BABA=pd.read_csv("data/BABA.csv")
    df_CRM=pd.read_csv("data/CRM.csv")
    df_FB=pd.read_csv("data/FB.csv")
    df_GOOG=pd.read_csv("data/GOOG.csv")
    df_INTC=pd.read_csv("data/INTC.csv")
    df_MSFT=pd.read_csv("data/MSFT.csv")
    df_NVDA=pd.read_csv("data/NVDA.csv")
    df_TSLA=pd.read_csv("data/TSLA.csv")

    Thanks to the Datacamp platform, we can display any dataframe we want and sort it by ascending or descending order by any column we want. We can take the Amazon dataframe as an example:

    df_AMZN

    Then we can create a new column called "Stock Value Evolution" for each dataframe, calculated by substracting the values in the 'Open' column from the values in the 'Close' column.

    df_AAPL['Stock Value Evolution']=df_AAPL['Close'] - df_AAPL['Open']
    df_BABA['Stock Value Evolution']=df_BABA['Close'] - df_BABA['Open']
    df_AMZN['Stock Value Evolution']=df_AMZN['Close'] - df_AMZN['Open']
    df_CRM['Stock Value Evolution']=df_CRM['Close'] - df_CRM['Open']
    df_FB['Stock Value Evolution']=df_FB['Close'] - df_FB['Open']
    df_GOOG['Stock Value Evolution']=df_GOOG['Close'] - df_GOOG['Open']
    df_INTC['Stock Value Evolution']=df_INTC['Close'] - df_INTC['Open']
    df_MSFT['Stock Value Evolution']=df_MSFT['Close'] - df_MSFT['Open']
    df_NVDA['Stock Value Evolution']=df_NVDA['Close'] - df_NVDA['Open']
    df_TSLA['Stock Value Evolution']=df_TSLA['Close'] - df_TSLA['Open']
    

    We can see what it looks like in the following cell :

    df_AAPL.head()

    For further analysis, we can filter already the 'Date' column in order to have dataframes with only the values provided after the year 2015. We will call the new dataframes by their names following with the suffix "_bis".

    df_AAPL_bis=df_AAPL[df_AAPL['Date']>'2015-12-31']
    df_AMZN_bis=df_AMZN[df_AMZN['Date']>'2015-12-31']
    df_BABA_bis=df_BABA[df_BABA['Date']>'2015-12-31']
    df_CRM_bis=df_CRM[df_CRM['Date']>'2015-12-31']
    df_GOOG_bis=df_GOOG[df_GOOG['Date']>'2015-12-31']
    df_FB_bis=df_FB[df_FB['Date']>'2015-12-31']
    df_INTC_bis=df_INTC[df_INTC['Date']>'2015-12-31']
    df_MSFT_bis=df_MSFT[df_MSFT['Date']>'2015-12-31']
    df_NVDA_bis=df_NVDA[df_NVDA['Date']>'2015-12-31']
    df_TSLA_bis=df_TSLA[df_TSLA['Date']>'2015-12-31']

    Now we can use the 'Date' column as the index and transform it into a datetime object.

    #Set 'Date' column to index
    df_AAPL=df_AAPL.set_index('Date')
    
    #Transform the index to datetime type for further analyses
    df_AAPL.index=pd.to_datetime(df_AAPL.index)