Pandas QUERY // Examples of pandas query with MULTIPLE CONDITIONS and pandas query with a VARIABLE

preview_player
Показать описание
Learn how to filter Python pandas dataframes using the pandas query method. This video shows you how to write strings needed for the pandas query and compares those to writing pandas masks. I'll show you how to reference columns with spaces by using back ticks. And you can level up your Python pandas code by writing a query with a variable using the at symbol. I'll also show you examples of how to use pandas query with multiple conditions such as making sure two different pandas columns satisfy conditional statements with query, or by to use pandas query or, which makes sure at least one conditional is true. Finally, you'll learn how to make your changes permanent by using the Python pandas query option inplace. Check out this video in my "Pandas Tips" series to see pandas tips and tricks in a quick pandas tutorial format.

0:00 Introduction
0:23 Set up and data
0:45 Query vs Mask
2:21 Columns with SPACES
3:26 Reference VARIABLES
5:22 AND &
7:00 OR |
7:31 Save changes: inplace
8:07 Conclusion & BLOOPS

💻 Github CODE 💻

🎥 Related VIDEOS 🎥
• Full Pandas Tips series:

📖 BOOKS about pandas from my Amazon Storefront 📖

☕ Buy me a COFFEE ☕
If you have enjoyed the content presented in this video and are able, consider buying a virtual cup of coffee to keep my channel going!

#python #pandas #pythonprogramming
Рекомендации по теме
Комментарии
Автор

Nice video, thx! More information about query:
- u can check value in column is in the list using 2 methods:
query('col1 in @list_') or less logical query('col1 == @list_')
- u can use keywords AND, OR, NOT instead of operators &, |, ~
- u can use straightforwardly pandas built-in methods (include string and date ones):
query('col1.str.contains("A") and col2.dt.year==2024 and not col3.isna()')

ИванАвито-иэ
Автор

it's a great video, thanks for sharing it, Kimberly!

goodmanshawnhuang
Автор

Thanks for the concise explanation, Kim!

rskura
Автор

Nice explanation. I will like to see lambda function in pandas in the nearest future. Welldone 👍

idris
Автор

Nice job. The use of the @ symbol is slick. Thanks!

ziggle
Автор

Nice video! I always learn something after watching your videos. Thanks!

jas
Автор

This video was very, very great
Thank you very much
Will you be uploading new videos? 😊

maziarzamani
Автор

Is there a possibility that you could start a machine learning course (from beginner to advanced)

hariharanganesan
Автор

Hi dear! How are you? Do you teach JavaScript also?

easyprogramminglessons
Автор

Hello mam....i have error in seaborn i type
import seaborn as sns than i press only run without any entering datafram etc so there coming error

I not getting proper solution

I uploaded video short in my channel

gkw
Автор

I find conditional row selection in square brackets the ugliest thing.

The Pandas team seem to override every [] with their own functions.

FelipeCampelo