Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Use pandas DataFrames on Excel Data

In this lab, we take a .csv file and create an Excel workbook out of it using pandas. The pdf of the notebook for this lab is [here.](https://github.com/linuxacademy/content-python-for-database-and-reporting/blob/master/pdf/hol_4_2_l_solution.pdf)

Google Cloud Platform icon
Lab platform
Lab Info
Level
Beginner
Last updated
Sep 21, 2025
Duration
30m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Start Jupyter Notebook Server and Access on Your Local Machine

    Connecting to the Jupyter Notebook Server

    Make sure that you have activated the virtual environment!

    1. Use the following to activate the virtual environment:
    conda activate base
    
    1. To start the server, run the following:
    python get_notebook_token.py
    

    This is a simple script that starts the Jupyter notebook server and sets it to continue to run outside of the terminal.

    On the terminal is a token, please copy this and save it to a text file on your local machine.

    On Your Local Machine

    1. In a terminal window, enter the following:
    ssh -N -L localhost:8087:localhost:8086 cloud_user@<the public IP address of the Playground server>
    

    It will ask you for your password; this is the password you use to login to the Playground remote server.

    Leave this terminal open, it will appear nothing has happened, but it must remain open while you use the Jupyter Notebook server in this session.

    1. In the browser of your choice, enter the following address:

    http://localhost:8087

    This will open a Jupyter Notebook site that asks for the token you copied from the remote server.

  2. Challenge

    Read the File Into a DataFrame
    # open file for reading
    f = open('dow_jones_index.data')
    
    # print the first two lines
    print(f.readline())
    print(f.readline())
    
    f.close()
    

    It appears the file is CSV. Read the file into a dataframe.

    import pandas as pd
    
    stock_df = pd.read_csv('dow_jones_index.data')
                           
    stock_df.head()
    
  3. Challenge

    Create the Excel Workbook

    Create a dataframe for each of the requested stocks

    ge_df = stock_df[stock_df.stock=='GE']
    ibm_df = stock_df[stock_df.stock=='IBM']
    krft_df = stock_df[stock_df.stock=='KRFT']
    

    Write the Excel file

    with pd.ExcelWriter('stocks.xlsx') as writer:  
        ge_df.to_excel(writer, sheet_name='GE')
        ibm_df.to_excel(writer, sheet_name='IBM')
        krft_df.to_excel(writer, sheet_name='KRFT')
    
    
  4. Challenge

    Check the Excel Workbook Contains the Requested Data

    Load the file into an ordered dict dataframe and then check that each worksheet is populated.

    my_stock_df = pd.read_excel('stocks.xlsx', sheet_name=None)  
    
    my_stock_df.keys()
    
    my_stock_df['GE']
    
    my_stock_df['IBM']
    
    my_stock_df['KRFT']
    
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight