Why does to_datetime produce only missing values for a float column in pandas?
The best way might be to avoid floats altogether. Preempt the conversion to numerics in read_table by specifying dtype, with the column in question being kept an object. to_datetime handles that as intended.
HT: BrenBarn in the comments.
I am confused by something in pandas 0.18.0. In my input csv data, a field is supposed to consist dates as YYYYMMDD strings, but some rows have this missing or misformatted. I want to represent this column as datetime with dates where possible, and missing where not.
I tried several options, and what got me furthest was not using parse_dates upon reading the table in (with read_table), but then coercing the conversion with pandas.to_datetime(DataFrame['Seriesname'],  errors='coerce',format='%Y%m%d'). This is robust to typos where the number cannot represent a date (think '20100231', column imported as int64 first) or when the string does not represent a number at all (think '2o1oo228', column an object upon import).
What this procedure is not robust to is when the columns contains only numbers but one field is empty. Then read_table imports the entire column as a float64 (not an int64, which has no missing values in numpy), and the conversion above produces all missing, even for rows where the data makes sense.
Is there a way around this?