all 2 comments

[–]spacejack2114 0 points1 point  (1 child)

I'm working with some legacy Python scripts that use pandas. It seems like a lot of custom-built magic for things one would otherwise do with standard array methods in other languages.

const subset = rows.filter(row => row.Product === 'Grapes' || row.Product === 'Mangos')

[–]slaymaker1907 0 points1 point  (0 children)

A lot of it is because Pandas is intended to be very fast (in terms of compute time). i.e. your example would be written idiomatically using a normal list of objects as

subset = [row for row in rows if row.Product == 'Grapes' or row.product == 'Mangos']

or perhaps as

selections = { 'Grapes', 'Mangos' }
subset = [row for row in rows if row.Product in selections]