Preppin' Data 2021 WK01 in Python

Last week I wrote a blog on completing the Preppin' Data 2021 WK01 challenge in SQL. This week I challenged myself to complete it in Python. I am uploading my solutions for each Preppin' Data challenge on Git Hub. Feel free to check it out here: https://github.com/Dan-Booth-Data/PreppinData/tree/main


Similarly to last week I am starting with this dataset:

I loaded in the data using the read_csv() function from the Pandas library.

Task 1:

To do this I used the str.split() function and split at any '-' with a trailing and leading space.

Task 2:

I decided the easiest way to achieve this was to correct the names based on their first value. To do this I made a dictionary which I could run across the first letter of each value.

Task 3:

To complete this task, I firstly needed to convert the date column to a date datatype. I could then use the built in functions from the dt library to extract the quarter and day of month.

Task 4:

To achieve this I filtered out the first 10 Order ID's.

Final Output:

Lastly I removed any columns that were no longer needed.

Author:
Dan Booth
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2025 The Information Lab