擅长:python、mysql、java
<p>您需要使用pandas.read_csv而不是python的csv。</p>
<p>在这里,可以使用dtype参数为其提供正确的数据类型,以便其使用:</p>
<p>来自熊猫<a href="http://pandas.pydata.org/pandas-docs/stable/io.html" rel="nofollow noreferrer">documentation</a></p>
<blockquote>
<p>dtype : Type name or dict of column -> type, default None Data type
for data or columns. E.g. {'a': np.float64, 'b': np.int32}
(unsupported with engine='python'). Use str or object to preserve and
not interpret dtype.</p>
</blockquote>
<p>如果必须在pandas外部解析CSV,则可以使用“from_records”导入,强制使用float=True。<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.from_records.html" rel="nofollow noreferrer">Reference</a></p>
<blockquote>
<p>coerce_float : boolean, default False Attempt to convert values to
non-string, non-numeric objects (like decimal.Decimal) to floating
point, useful for SQL result sets</p>
</blockquote>