Key Facts
- Category
- Data Processing
- Input Types
- textarea, select, text
- Output Type
- text
- Sample Coverage
- 4
- API Ready
- Yes
Overview
The Remove By Predicate tool uses lodash's _.remove function to filter out elements from a JSON array based on specified conditions. It supports numeric and string comparisons, enabling quick data cleaning and preprocessing by returning the remaining array as JSON.
When to Use
- •When you need to remove specific items from an array based on a condition like greater-than or string-contains.
- •For data cleaning tasks, such as eliminating outliers, null values, or invalid entries from datasets.
- •To preprocess arrays before further analysis, transformation, or integration into other workflows.
How It Works
- •Input a valid JSON array in the provided text area.
- •Select a predicate type from the dropdown, such as 'greater-than' or 'string-contains'.
- •Enter a compare value if required by the predicate (e.g., a number or string).
- •The tool processes the array using lodash _.remove and outputs the filtered array as JSON.
Use Cases
Examples
1. Remove Numbers Above a Threshold
Data Analyst- Background
- You have an array of test scores and want to remove all scores above 100 to focus on lower performers for analysis.
- Problem
- Manually filtering large arrays is time-consuming and prone to errors.
- How to Use
- Enter the array of scores, select 'greater-than' as the predicate, and set the compare value to 100.
- Outcome
- The tool returns an array with all scores less than or equal to 100, ready for further statistical review.
2. Filter Strings by Substring
Content Manager- Background
- You have a list of article titles and need to remove those that don't contain a specific keyword for SEO optimization.
- Problem
- Searching through titles manually is inefficient and slows down content curation.
- How to Use
- Input the array of titles, choose 'string-contains' as the predicate, and enter the keyword as the compare value.
- Outcome
- The resulting array contains only titles that include the specified keyword, streamlining the selection process.
Try with Samples
json, videoRelated Hubs
FAQ
What predicates are supported?
The tool supports predicates like less-than, greater-than, equals, not-equals, string-contains, string-starts-with, string-ends-with, is-nullish, is-truthy, and is-falsey.
Is the compare value always required?
No, for predicates like is-nullish, is-truthy, or is-falsey, the compare value is not needed.
Can I use this tool with arrays of objects?
The tool is designed for arrays of primitive values like numbers or strings. For objects, extract specific properties first.
What happens if the array is empty?
The tool will return an empty array as the result, with no elements removed.
Does the tool modify the original array?
No, it returns a new array with matching elements removed, leaving the original input unchanged.