I"m reading in a csv file with multiple datetime columns. I"d need to set the data types upon reading in the file, but datetimes appear to be a problem. For instance:
headers = ["col1", "col2", "col3", "col4"] dtypes = ["datetime", "datetime", "str", "float"] pd.read_csv(file, sep=" ", header=None, names=headers, dtype=dtypes)
When run gives a error:
TypeError: data type "datetime" not understood
Converting columns after the fact, via pandas.to_datetime() isn"t an option I can"t know which columns will be datetime objects. That information can change and comes from whatever informs my dtypes list.
Alternatively, I"ve tried to load the csv file with numpy.genfromtxt, set the dtypes in that function, and then convert to a pandas.dataframe but it garbles the data. Any help is greatly appreciated!