4

I'm trying to read in a csv file using pandas (0.8.1) using the dtype parameter and am having an error.

My csv file structure looks like this:

"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"

The reason I need to specify the dtype is because the first two columns USAF,WBAN need to be string since they sometimes start with zeros, and when I read regularly it converts a number like 0006852 into 6852. Here's the code I'm using:

import pandas as pd
df = pd.io.parsers.read_csv("Station Codes.csv", dtype={'USAF': np.str, 'WBAN': np.str})

results in the following error:

TypeError: read_csv() got an unexpected keyword argument 'dtype'

I don't understand why it's saying that its an unexpected keyword argument when I see the documentation here: http://pandas.pydata.org/pandas-docs/dev/generated/pandas.io.parsers.read_csv.html

Am I missing something here?

smci
  • 32,567
  • 20
  • 113
  • 146
Radical Edward
  • 5,234
  • 5
  • 21
  • 33

1 Answers1

3

The dtype argument was introduced in 0.10.
Upgrade to the latest stable release for the latest and greatest features and bug fixes.

Andy Hayden
  • 359,921
  • 101
  • 625
  • 535
  • Thanks that was it I was on 0.8.1. Still doesn't like the np.str but that's for another question :/ – Radical Edward Jun 04 '13 at 22:58
  • I tried that and was still getting the same error. New question here: http://stackoverflow.com/questions/16929056/pandas-read-csv-dtype-leading-zeros – Radical Edward Jun 04 '13 at 23:20