I have a code that I am trying to optimize by combining similar steps in one line and it it failing. Any suggestion? I am new to Python and Pandas