Calculated basis statistics from data in Python