1

In lodash I can use the syntax: find(ARRAY_OF_OBJECTS, OBJECT) This will return an object from the array if it meets the criteria of the passed object. In this case OBJECT would be e.g. { active: true, dimension: 'target' }. The objects in the array would contain e.g. active, dimension, status etc.

How can I do the same in pydash? I know I can do find(ARRAY_OF_OBJECTS, lambda x: x.active == True, but the thing is, the object I pass is dynamically made. So sometimes it might not have active (as example)

Edgar Koster
  • 479
  • 1
  • 5
  • 18

1 Answers1

1

Figured it out. I can do it with is_match from pydash. In a complete line of code it would become this. target_data is an array of objects and source_row['dimensions'] is an object

py_.collections.find(target_data, lambda x: py_.predicates.is_match(x, source_row['dimensions']))

Edgar Koster
  • 479
  • 1
  • 5
  • 18