擅长:python、mysql、java
<p>由于字符串数据类型具有可变长度,因此它默认存储为对象数据类型。如果要将它们存储为字符串类型,可以执行以下操作。</p>
<pre><code>df['column'] = df['column'].astype('|S80') #where the max length is set at 80 bytes,
</code></pre>
<p>或者</p>
<pre><code>df['column'] = df['column'].astype('|S') # which will by default set the length to the max len it encounters
</code></pre>