Work-Life Balance: Take A Dive Into Datasets

JoeWebDesigns
FAUN — Developer Community 🐾

--

Introduction

In this article, we take a dive into a dataset which describes the best cities to live in for work-life balance in 2022. We will use this dataset to answer various questions directed from individuals who have different motivations when it comes to inhabiting a city. We will import the dataset, carry out some pre-cleaning and then answer the questions. The first question contains two parts; where both involve ranking cities based on a client’s needs — if you watched Climbing in the 2021 Olympics, you’ll recognise this method of scoring. Adam Ondra would be proud! The second question involves geo-spatial mapping to visually show the cities that best meet the client’s criteria; providing data-driven insights on how to optimise their holiday plans (e.g. where to fly to, holiday itineraries, and where to fly back home from). Remember that the lessons learned here may come in handy when planning your next big holiday, city break, or even relocation relocation relocation…

Data Import and Cleaning

1. Import Libraries
2. Import Work-Life Balance Dataset

Note: The backslash ‘\’ will be used throughout to continue the code to the next line.

3. Dataset Structure (Pre-cleaning)

Notice that some of the object columns should be integer or float columns. We will therefore carry out some cleaning.

4. Data Cleaning

Let’s have a look again at the structure of the dataset to see whether our spring cleaning has been useful.

5. Dataset Structure (Post-cleaning)

Brilliant. Now let’s have a quick look at the dataset to see what we have.

6. Work-Life Balance Dataset Snapshot

Question 1a)

Martha is a young graduate who wants to move to a French speaking city and find a job. She wants to live in a city that meets her following needs: i) maximises the chances of being offered more vacation days per year, ii) maximises her chances of remote working, iii) minimises her chances of being impacted by covid-19. Martha has informed us that each need is of equal importance.

7. Filtering of Work-Life Balance DataFrame to Capture French Speaking Countries, and Also Columns that Relate Specifically to Martha’s Needs
8. Martha’s DataFrame
9. Create Ranking System for Martha’s DataFrame
10. Martha‘s City Rankings

Recommendation: Martha should choose Paris as her first choice, Geneva as her second choice, and Brussels as her third choice.

Question 1b)

Martha has had a re-think and decides that the chosen city must also meet the following conditions: i) it must have an affordability score above 60, and ii) it must have a minimum score of 80 on outdoor spaces, to cater for her early morning runs.

11. Martha’s Re-think (Includes Conditions on Affordability and Outdoor Spaces)

Recommendation: Based on Martha’s additional conditions that must be met, as well as her needs outlined in Q1a), the best matched city is Geneva. The second best is Toronto and the third best is Ottawa. The latter two cities are poorer matches (notice their higher overall rankings), so if Martha would like to have a wider selection of matches that better suits her needs, she may have to be more relaxed with regards to affordability and/or outdoor spaces.

Question 2)

Martha’s friend John is planning his next 2-week holiday. He lives in Edinburgh, and he wants to travel to at least 5 cities — all of which must be known to be ‘up-and-coming’. Can you make any good travel/holiday suggestions?

We will make the assumption that ‘up-and-coming’ cities are those that have not made the top 50 ranking in 2021, but have made the top 25 ranking in 2022.

12. ‘Up and Coming’ Cities

We now need to obtain the latitudes and longitudes of the ‘up and coming’ cities so we can later find their coordinates on the globe. Therefore, we import a world cities database — in the form of a DataFrame — that contains this information, allowing us to look for matches between city names and countries (both are important because there are many cities called Glasgow across the globe, etc). Then we can insert the relevant latitudes and longitudes into the ‘up and coming’ DataFrame.

13. Incorporate City Coordinates Into ‘Up and Coming’ DataFrame

The above latitudes and longitudes in the ‘up and coming ‘ DataFrame need to be converted to coordinates that are compatible with the GeoPandas library - to allow us to plot the city locations on a world map. Note: we imported the geopandas library as ‘gpd’ in Figure 1.

14. ‘Up and Coming’ Converted to a GeoDataFrame with City Coordinates
15. Create Annotated Map of Europe Illustrating ‘Up and Coming’ Cities
16. Annotated Map of Europe

Recommendation: John could travel from Edinburgh to Glasgow, stay for a couple of days, fly to Bremen in Northern Germany, snake his way southwards via German cities (shown in the annotated map), and finish up in Switzerland, eventually flying home from Geneva. He could instead choose to do this in reverse, or decide to go with some other permutation. Overall, John has the choice of which Swiss and German cities he wants to travel to, and whether he wants to incorporate Glasgow into his travels. The only city that doesn’t make sense to visit is Liverpool, as he would have to go quite out of his way!

Acknowledgements

Work-Life Balance Dataset: Thanks to Prasert Kanawattanacha for uploading this dataset to Kaggle → Link here

World_Cities Database: Thanks to Juanma Hernández for uploading this database / dataset to Kaggle → Link here

If this post was helpful, please click the clap 👏 button below a few times to show your support for the author 👇

🚀Developers: Learn and grow by keeping up with what matters, JOIN FAUN.

--

--