I'm reading a csv file. Each row has different values, but I'm only interested in first and second values, which have the following format:
2015-11-02 10:07:33,2015-11-02 10:07:52
I need to get the elapsed time between both. My code is:
file = pd.read_csv('file.csv', header=None, skiprows=1, index_col=False,
chunksize=1000000, usecols=[1, 2], names=['ts', 'te'], na_values=['n/a','N/A','nan','NaN'],
dtype={'ts':datetime, 'te':datetime})
for chunk in file:
chunk['duration'] = chunk['te']-chunk['ts']
But I get the following error:
TypeError: unsupported operand type(s) for -: 'str' and 'str'
What can I do? Thank you very much.
Update: My problem is solved. But now I need to cast every time elapsed chunk into a float. Thank you.