擅长:python、mysql、java
<p>我假设帐号的指数符号必须来自数据文件。如果我用完整的帐号创建一个小型csv,pandas会将它们解释为整数。</p>
<pre><code> acct_num
0 4118890000
1 9876543210
df['acct_num'].dtype
Out[51]: dtype('int64')
</code></pre>
<p>但是,如果csv中的帐号是用指数表示的,那么pandas将把它们读为float。</p>
<pre><code> acct_num
0 4.118890e+11
1 9.876543e+11
df['acct_num'].dtype
Out[54]: dtype('float64')
</code></pre>
<p>你有两个选择。首先,更正创建csv的过程,以便正确地写出帐号。第二种方法是将acct_num列的数据类型更改为integer。</p>
<pre><code>df['acct_num'] = df['acct_num'].astype('int64')
df
Out[66]:
acct_num
0 411889000000
1 987654321000
</code></pre>