read_csv should promote int values to float64 if column contains NaNs
Versions: WinXP, pd 13.1, np-1.7.1, numexpr-2.2.2

Consider the following code snippit:

from io import StringIO
import pandas as pd
import numpy as np

data = 'a;b;c\n1;2;3\n4;NaN;6\n7;8;9'

df = pd.read_csv(StringIO(data),
sep = ';', dtype = np.float64)
print(df.b)

df2 = pd.read_csv(StringIO(data),
    sep = ';', dtype = np.int)

It terminates as follows:

In [77]: run test
0     2
1   NaN
2     8
## Name: b, dtype: float64

Exception                                 Traceback (most recent call last)
c:\python33\lib\site-packages\IPython\utils\py3compat.py in execfile(fname, glob
, loc)
     98         loc = loc if (loc is not None) else glob
     99         with open(fname, 'rb') as f:
--> 100             exec(compile(f.read(), fname, 'exec'), glob, loc)
    101
    102     # Refactor print statements in doctests.

C:\Dokumente und Einstellungen\stefan\Eigene Dateien\dev\economics\stats\imf\tes
t.py in <module>()
     11
     12 df2 = pd.read_csv(StringIO(data),
---> 13     sep = ';', dtype = np.int)
     14 print(df2.b)
     15

c:\python33\lib\site-packages\pandas\io\parsers.py in parser_f(filepath_or_buffe
r, sep, dialect, compression, doublequote, escapechar, quotechar, quoting, skipi
nitialspace, lineterminator, header, index_col, names, prefix, skiprows, skipfoo
ter, skip_footer, na_values, na_fvalues, true_values, false_values, delimiter, c
onverters, dtype, usecols, engine, delim_whitespace, as_recarray, na_filter, com
pact_ints, use_unsigned, low_memory, buffer_lines, warn_bad_lines, error_bad_lin
es, keep_default_na, thousands, comment, decimal, parse_dates, keep_date_col, da
yfirst, date_parser, memory_map, nrows, iterator, chunksize, verbose, encoding,
squeeze, mangle_dupe_cols, tupleize_cols, infer_datetime_format)
    418                     infer_datetime_format=infer_datetime_format)
    419
--> 420         return _read(filepath_or_buffer, kwds)
    421
    422     parser_f.__name__ = name

c:\python33\lib\site-packages\pandas\io\parsers.py in _read(filepath_or_buffer,
kwds)
    223         return parser
    224
--> 225     return parser.read()
    226
    227 _parser_defaults = {

c:\python33\lib\site-packages\pandas\io\parsers.py in read(self, nrows)
    624                 raise ValueError('skip_footer not supported for iteratio
n')
    625
--> 626         ret = self._engine.read(nrows)
    627
    628         if self.options.get('as_recarray'):

c:\python33\lib\site-packages\pandas\io\parsers.py in read(self, nrows)
   1068
   1069         try:
-> 1070             data = self._reader.read(nrows)
   1071         except StopIteration:
   1072             if nrows is None:

c:\python33\lib\site-packages\pandas\parser.pyd in pandas.parser.TextReader.read
 (pandas\parser.c:7110)()

c:\python33\lib\site-packages\pandas\parser.pyd in pandas.parser.TextReader._rea
d_low_memory (pandas\parser.c:7334)()

c:\python33\lib\site-packages\pandas\parser.pyd in pandas.parser.TextReader._rea
d_rows (pandas\parser.c:8159)()

c:\python33\lib\site-packages\pandas\parser.pyd in pandas.parser.TextReader._con
vert_column_data (pandas\parser.c:9367)()

c:\python33\lib\site-packages\pandas\parser.pyd in pandas.parser.TextReader._con
vert_tokens (pandas\parser.c:9929)()

c:\python33\lib\site-packages\pandas\parser.pyd in pandas.parser.TextReader._con
vert_with_dtype (pandas\parser.c:10412)()

Exception: Integer column has NA values

In [78]:
