EXERCISE TOPIC▼
- Access exercises (91)
- C# exercises (79)
- Excel exercises (278)
- Power Apps exercises (13)
- Power Automate exercises (18)
- Power BI exercises (139)
- Power Platform exercises (157)
- Python exercises (28)
- Report Builder exercises (141)
- SQL exercises (198)
- SSAS exercises (51)
- SSIS exercises (46)
- SSRS exercises (99)
- VBA exercises (85)
- Visual Basic exercises (46)
PYTHON EXERCISES▼
PYTHON EXERCISES▼
Python | Overview of Pandas exercise | Reading in a dataframe, renaming columns and showing stats
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
Software ==> | Python (28 exercises) |
Version ==> | Latest version |
Topic ==> | Overview of Pandas (1 exercise) |
Level ==> | Average difficulty |
Subject ==> | Python training |
You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
The Excel workbook above contains the results to date of this year's Poohsticks tournament in the Hundred Acre Wood:

Tigger is leading, although Pooh Bear and Roo have only played two games each.
Import the Pandas module in a new program, then read this workbook into a Pandas dataframe and show information for this using the info method:

Set your dataframe variable to be the results of running the pd.read_excel method of the Pandas module.
Apply the sort_values method to your dataframe to sort the rows by Poohsticks score (highest first) and within this by games played, then pick out the first 3 rows using the head function to show the current 3 leaders:

The leaderboard as things stand.
Apply the rename method to your dataframe, passing in a dictionary of objects where the key is the old name of each column and the value is the new name, to get this:

The dataframe with its new column names.
Finally apply the agg function to your final dataframe, passing in a dictionary where the key to each item is the name of each integer column and the value is a list of statistical functions you want to apply, to get:

The minimum, maximum, median and average score and number of games played.
Close your program down!