Port of system python code to Pandas