我正在尝试使用dtype参数使用pandas(0.8.1)读取csv文件并且出错。
我的csv文件结构如下所示:
"USAF","WBAN","STATION NAME","CTRY","FIPS","STATE","CALL","LAT","LON","ELEV(.1M)","BEGIN","END"
"006852","99999","SENT","SW","SZ","","","+46817","+010350","+14200","",""
"007005","99999","CWOS 07005","","","","","-99999","-999999","-99999","20120127","20120127"
我需要指定dtype的原因是因为前两列USAF
,WBAN
需要是字符串,因为它们有时以零开头,而当我经常阅读时它会转换为0006852之类的数字这是我正在使用的代码:
import pandas as pd
df = pd.io.parsers.read_csv("Station Codes.csv", dtype={'USAF': np.str, 'WBAN': np.str})
导致以下错误:
TypeError: read_csv() got an unexpected keyword argument 'dtype'
当我在这里看到文档时,我不明白为什么它说它是一个意想不到的关键字参数: http://pandas.pydata.org/pandas-docs/dev/generated/pandas.io.parsers.read_csv.html
我在这里错过了什么吗?