- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
LeetCode 570 - Managers With at Least 5 Direct Reports (Python and SQL) [Medium]
🧠 Don’t miss out! Get FREE access to my Skool community — packed with resources, tools, and support to help you with Data, Machine Learning, and AI Automations! 📈 https://www.skool.com/data-and-ai-automations-4579
In this tutorial, we walk through LeetCode Problem 570: Managers With at Least 5 Direct Reports using both SQL and Python (Pandas). This is a great exercise in grouping, counting, and filtering—key skills for interviews and real-world data work!
LeetCode Question: https://leetcode.com/problems/managers-with-at-least-5-direct-reports/description/
🚀 Hire me for Data Work: https://ryanandmattdatascience.com/data-freelancing/
👨💻 Mentorships: https://ryanandmattdatascience.com/mentorship/
📧 Email: ryannolandata@gmail.com
🌐 Website & Blog: https://ryanandmattdatascience.com/
🖥️ Discord: https://discord.com/invite/F7dxbvHUhg
📚 *Practice SQL & Python Interview Questions: https://stratascratch.com/?via=ryan
📖 *SQL and Python Courses: https://datacamp.pxf.io/XYD7Qg
🍿 WATCH NEXT
LeetCode Playlist: https://www.youtube.com/playlist?list=PLcQVY5V2UY4J_wlwSXiEuf2KrEBan0Ysv
LeetCode 586: https://youtu.be/0mRrOh2LJIM
LeetCode 595: https://youtu.be/W4swQ3A4Djc
LeetCode 619: https://youtu.be/ZPG85SGgI-Q
In this video, I walk through LeetCode problem 570, which asks you to find managers with at least five direct reports. This medium-difficulty problem is a great example of using self-joins in SQL and merge operations in Python pandas. I show you both solutions line by line, explaining exactly why each step is necessary.
We start with the SQL approach, where I demonstrate how to self-join the employee table to map manager IDs to manager names. I explain the group by clause and why we need to include both the manager name and manager ID to handle edge cases where multiple managers share the same name. Then I use a having clause to filter for managers with five or more reports.
Next, I tackle the same problem using Python pandas. I show how to use groupby and size to count reports, filter the results, and then merge the filtered data frame back with the original employee table to get the manager names. I also troubleshoot a common bracket error that many pandas users encounter when selecting columns.
By the end of this tutorial, you will understand self-joins in SQL, the having clause, pandas merge operations, and how to approach medium-level LeetCode SQL and pandas problems. Perfect for data analyst and data science interview prep.
TIMESTAMPS
00:00 Problem Introduction
00:40 Understanding the Example Input
01:00 SQL Solution - Self Join Setup
02:00 SQL Solution - Group By & Having Clause
02:50 SQL Code Review & Walkthrough
03:50 Python Pandas Solution - Group By & Size
04:40 Python Pandas - Filtering Results
05:10 Python Pandas - Merging DataFrames
06:20 Final Solution Review
OTHER SOCIALS:
Ryan’s LinkedIn: https://www.linkedin.com/in/ryan-p-nolan/
Matt’s LinkedIn: https://www.linkedin.com/in/matt-payne-ceo/
Twitter/X: https://x.com/RyanMattDS
Who is Ryan
Ryan is a Data Scientist at a fintech company, where he focuses on fraud prevention in underwriting and risk. Before that, he worked as a Data Analyst at a tax software company. He holds a degree in Electrical Engineering from UCF.
Who is Matt
Matt is the founder of Width.ai, an AI and Machine Learning agency. Before starting his own company, he was a Machine Learning Engineer at Capital One.
*This is an affiliate program. We receive a small portion of the final sale at no extra cost to you.
Видео LeetCode 570 - Managers With at Least 5 Direct Reports (Python and SQL) [Medium] канала Ryan & Matt Data Science
In this tutorial, we walk through LeetCode Problem 570: Managers With at Least 5 Direct Reports using both SQL and Python (Pandas). This is a great exercise in grouping, counting, and filtering—key skills for interviews and real-world data work!
LeetCode Question: https://leetcode.com/problems/managers-with-at-least-5-direct-reports/description/
🚀 Hire me for Data Work: https://ryanandmattdatascience.com/data-freelancing/
👨💻 Mentorships: https://ryanandmattdatascience.com/mentorship/
📧 Email: ryannolandata@gmail.com
🌐 Website & Blog: https://ryanandmattdatascience.com/
🖥️ Discord: https://discord.com/invite/F7dxbvHUhg
📚 *Practice SQL & Python Interview Questions: https://stratascratch.com/?via=ryan
📖 *SQL and Python Courses: https://datacamp.pxf.io/XYD7Qg
🍿 WATCH NEXT
LeetCode Playlist: https://www.youtube.com/playlist?list=PLcQVY5V2UY4J_wlwSXiEuf2KrEBan0Ysv
LeetCode 586: https://youtu.be/0mRrOh2LJIM
LeetCode 595: https://youtu.be/W4swQ3A4Djc
LeetCode 619: https://youtu.be/ZPG85SGgI-Q
In this video, I walk through LeetCode problem 570, which asks you to find managers with at least five direct reports. This medium-difficulty problem is a great example of using self-joins in SQL and merge operations in Python pandas. I show you both solutions line by line, explaining exactly why each step is necessary.
We start with the SQL approach, where I demonstrate how to self-join the employee table to map manager IDs to manager names. I explain the group by clause and why we need to include both the manager name and manager ID to handle edge cases where multiple managers share the same name. Then I use a having clause to filter for managers with five or more reports.
Next, I tackle the same problem using Python pandas. I show how to use groupby and size to count reports, filter the results, and then merge the filtered data frame back with the original employee table to get the manager names. I also troubleshoot a common bracket error that many pandas users encounter when selecting columns.
By the end of this tutorial, you will understand self-joins in SQL, the having clause, pandas merge operations, and how to approach medium-level LeetCode SQL and pandas problems. Perfect for data analyst and data science interview prep.
TIMESTAMPS
00:00 Problem Introduction
00:40 Understanding the Example Input
01:00 SQL Solution - Self Join Setup
02:00 SQL Solution - Group By & Having Clause
02:50 SQL Code Review & Walkthrough
03:50 Python Pandas Solution - Group By & Size
04:40 Python Pandas - Filtering Results
05:10 Python Pandas - Merging DataFrames
06:20 Final Solution Review
OTHER SOCIALS:
Ryan’s LinkedIn: https://www.linkedin.com/in/ryan-p-nolan/
Matt’s LinkedIn: https://www.linkedin.com/in/matt-payne-ceo/
Twitter/X: https://x.com/RyanMattDS
Who is Ryan
Ryan is a Data Scientist at a fintech company, where he focuses on fraud prevention in underwriting and risk. Before that, he worked as a Data Analyst at a tax software company. He holds a degree in Electrical Engineering from UCF.
Who is Matt
Matt is the founder of Width.ai, an AI and Machine Learning agency. Before starting his own company, he was a Machine Learning Engineer at Capital One.
*This is an affiliate program. We receive a small portion of the final sale at no extra cost to you.
Видео LeetCode 570 - Managers With at Least 5 Direct Reports (Python and SQL) [Medium] канала Ryan & Matt Data Science
Комментарии отсутствуют
Информация о видео
20 апреля 2024 г. 9:00:15
00:07:25
Другие видео канала
