'B': "{:0<4.0f}" | How should I read this?
<p>While studying <a href="http://pandas.pydata.org/pandas-docs/stable/style.html" rel="nofollow">Pandas Style</a>, I got to the following:</p>

<pre><code>df.style.format("{:.2%}")
</code></pre>

<p>Which I understand means, turn every value to 2 decimal places and add a <code>%</code> in the end.</p>

<p>Just after that, there is:</p>

<pre><code>df.style.format({'B': "{:0&lt;4.0f}", 'D': '{:+.2f}'})
</code></pre>

<p>How should I read <code>'B': "{:0&lt;4.0f}"</code>?</p>

<p>This is the "new" formatting string syntax, explained in <a href="https://docs.python.org/2/library/string.html#format-specification-mini-language" rel="nofollow">https://docs.python.org/2/library/string.html#format-specification-mini-language</a>.</p>

<ul>
<li>The first <code>0</code> means pad with "0"</li>
<li>The <code>&lt;</code> means <a href="https://docs.python.org/2/library/string.html#grammar-token-align" rel="nofollow">align</a> to the left (so the number will be followed by a bunch of 0's, e.g. '4' will be formatted as "400000â¦")</li>
<li>The <code>4</code> means the <a href="https://docs.python.org/2/library/string.html#grammar-token-width" rel="nofollow">minimum width</a> is 4 characters</li>
<li>The <code>.0</code> means the <a href="https://docs.python.org/2/library/string.html#grammar-token-precision" rel="nofollow">precision</a> is 0, i.e. don't show any decimal parts.</li>
<li>The <code>f</code> means the <a href="https://docs.python.org/2/library/string.html#grammar-token-type" rel="nofollow">type</a> is a fixed-point number.</li>
</ul>

<p>Examples:</p>

<pre><code>&gt;&gt;&gt; '{:0&lt;4.0f}'.format(1)
'1000'
&gt;&gt;&gt; '{:0&lt;4.0f}'.format(3.14)
'3000'
&gt;&gt;&gt; '{:0&lt;4.0f}'.format(26)
'2600'
&gt;&gt;&gt; '{:0&lt;4.0f}'.format(77777)
'77777'
&gt;&gt;&gt; '{:0&lt;4.0f}'.format(-3)
'-300'
</code></pre>

python python-2.7 pandas