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?

1
  • 1
    What version of pandas are you using? Commented Jun 4, 2013 at 22:14

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks that was it I was on 0.8.1. Still doesn't like the np.str but that's for another question :/
I tried that and was still getting the same error. New question here: stackoverflow.com/questions/16929056/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.