I am trying to import a space separated .dat file using pandas and strip values to make a date. The data looks like this (three rows of data taken from the entire dataset for reference):
2.0140000e+003 1.0000000e+000 1.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 2.7454583e+000 1.8333542e+002 -3.3580352e+001
2.0140000e+003 1.0000000e+000 2.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 -6.1330625e+000 2.5187292e+002 -1.3752231e+001
2.0140000e+003 1.0000000e+000 3.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 -3.0905729e+001 2.1295208e+002 -2.4507273e+001
The first six numbers make up the date (year, month, day, hour, minute, second).
I can import the data using:
df = pd.read_csv('daily.dat', sep='\s+', header=None)
and it is separated fine.
However, I would like to strip the first six entries of the row into a date. For example, from row one the first six numbers (or first six columns after importing to df
) should make:
2014-01-01 00:00:00
Help?