fwiw I'd never ask a "Data Scientist" to do this in an interview. This is data engineering work. If you get asked to do this in an interview for a "Data Scientist" position, just run away. Also, the code presented is far from production grade. I'd recommend running pylint over this code and correcting the warnings before considering this ready for anything.