I am watching a video about the concept of Cross Validation. Here is a code snippet from that video:
from sklearn.cross_validation import KFold
kf = KFold(25, n_folds=5, shuffle=False)
print '{}{:^61}{}'.format('Iteration', 'Training set observations', 'Testing set observations')
for iteration,data in enumerate(kf, start=1):
print '{:^9}{}{:^25}'.format(iteration, data[0], data[1])
My question, however, is about the formatting used within print: What does the {:^61}
do, for example? I have never seen the ^
within the braces used for print formatting. It is usually sth like {0:3.2f}
. I know that ^
can be used as XOR, but, what is it doing here?
Can somebody explain?