I got a file, which contains a timestamp like '15:05:26:811'.
If I try to import it into pandas with
data = pd.read_csv(file, sep='\t', names=['Time', 'x-data', index_col = False, dtype = float)
I get the error
ValueError: could not convert string to float: '15:05:26:811'
What do I have to do? Just remove "dtype = float"? This might work, but will this lead to problems?
CodePudding user response:
You can parse the string column to a datetime object after reading the csv:
data['Time'] = pd.to_datetime(data['Time'], format='%H:%M:%S:%f')
If you want to parse the string while reading the csv, add a dedicated parser: https://stackoverflow.com/a/17468012/5316326