Filter

The filter operation allows you to select rows from your dataset based on specified conditions. This is useful when you want to focus on a subset of your data that meets specific criteria.

The filter function often involves three components: property, operator, and value. Here's a brief explanation of each component:
- Property: The property refers to the attribute or feature of the elements in the collection you want to apply the filter on. In the context of data manipulation, it can be a column name in a DataFrame or a key in a dictionary.
- Operator: The operator is the comparison or logical operator used to define the condition for filtering. Common operators include equal (==), not equal (!=), less than (<), less than or equal to (<=), greater than (>), greater than or equal to (>=), and so on.
- Value: The value is the reference point or threshold used in the condition. It is the specific value you want to compare the property against using the chosen operator.
Example
Dataset:
Department | Sales |
---|---|
HR | 100 |
Finance | 200 |
HR | 150 |
IT | 300 |
Finance | 250 |
Filter rows where Sales > 200:
Department | Sales |
---|---|
IT | 300 |
Finance | 250 |
Updated 5 months ago