当我使用指定为object
的列运行以下代码时,我得到了警告
/opt/conda/lib/python3.6/site-packages/IPython/core/interactiveshell.py:2785: DtypeWarning: Columns (13) have mixed types. Specify dtype option on import or set low_memory=False.
interactivity=interactivity, compiler=compiler, result=result)
我还尝试设置low_memory=False
,并使用假低内存和指定数据类型,但错误不会消失
最奇怪的是,我在另外两个文件上使用了完全相同的代码,但没有出现错误
我能做什么
这是所有3个文件中最大的一个。它有超过400000行和14列。其他的有200000多行和170000多行
re = requests.get('https://s3.amazonaws.com/baywheels-data/202002-baywheels-tripdata.csv.zip')
zip_file = zipfile.ZipFile(io.BytesIO(re.content))
csvfile = zip_file.open('202002-baywheels-tripdata.csv')
df = pd.read_csv(csvfile)
df.to_csv('Ford02-2020.csv',index=False)
df2 = pd.read_csv('Ford02-2020.csv', dtype={'rental_access_method': object})
df2.head()
'rental_access_method'
的示例数据0 NaN
1 NaN
2 NaN
3 NaN
4 NaN
...
432349 app
432350 app
432351 app
432352 app
432353 app
Name: rental_access_method, dtype: object
目前没有回答
相关问题 更多 >
编程相关推荐