pydata/pandas — pull request #3797 by jreback (2013-06-07 19:06:19+00:00)
Title: BUG: (GH3795) better error messages for invalid dtype specifications in read_csv

ENH: accept 'str' as a dtype in read_csv to provide correct parsing

closes #3795
```
In [1]: df = DataFrame(np.random.rand(5,2),columns=list('AB'),index=['1A','1B','1C','1D','1E'])

In [2]: df
Out[2]:
A B
1A 0.096563 0.761440
1B 0.623102 0.538810
1C 0.498820 0.277789
1D 0.113544 0.723437
1E 0.381104 0.061758

In [3]: df.dtypes
Out[3]:
A float64
B float64
dtype: object

In [4]: path='test.csv'

In [5]: df.to_csv(path)

In [6]: pd.read_csv(path, dtype=str, index_col=0)
Out[6]:
A B
1A 0.09656290409114332 0.761440208545324
1B 0.6231015058315575 0.5388097714651147
1C 0.49881957371373464 0.27778943212477014
1D 0.11354443109778356 0.723437196012621
1E 0.38110436826261596 0.06175758774696094

In [7]: pd.read_csv(path, dtype=str, index_col=0).dtypes
Out[7]:
A object
B object
dtype: object
```

Invalid dtype specifciation, all ``TypeError``, slightly different messages depending on what you are doing (e.g. if its completely invalid or really a date spec)
```
In [8]: pd.read_csv(path, index_col=0, dtype={'A' : 'foo'})
TypeError: data type "foo" not understood

In [9]: pd.read_csv(path, index_col=0, dtype={'A' : 'datetime64'})
TypeError: the dtype