Simplified logic using two main if flows, one for pandas objects and the other one for numpy objects.