new, functional script in pandas to replace R filtration