Filtering by set or array of values?

Hello I am trying to use this Fips brush to filter my dataset. It looks like it outputs a set of values. I tried converting it into an array of values and then filtering my dataset by the array.

filteredFips = yearlyData.filter(({county_fips}) => county_fips === fips)

But I guess you can’t filter by an array of values. What is the best way to work with this Fips brush to filter my data?

Here is my notebook. Sorry in advance if this is an easy question.

1 Like

I guess you could try the following:

filteredFips = yearlyData.filter(o => fips.indexOf(o.county_fips) > -1)
1 Like

Thank you so much!

1 Like

fipsbrush already returns a Set. So instead of

filteredFips = yearlyData.filter(o => fips.indexOf(o.county_fips) > -1)


filteredFips = yearlyData.filter(o => fipscodes.has(o.county_fips))

and remove the fips cell.

That way you don’t have to search the entire fipscodes array for each datum.

Don’t be! :slight_smile:

1 Like

Oh sweet that is even easier. Thanks!