Pandas dataframe: truncate string fields : <p>I have a dataframe and would like to truncate each field to up to 20 characters. I've been naively trying the following:</p>

<pre><code>df = df.astype(str).apply(lambda x: x[:20])
</code></pre>

<p>however it has no effect whatsoever. If, however, I wanted to add an 'Y' to each field, this works like a charm:</p>

<pre><code>df = df.astype(str).apply(lambda x: x+'Y')
</code></pre>

<p>What am I doing wrong?</p>
