Datetime subtraction raises unsupported operand type(s) for -: 'str' and 'str' error

Viewed 37

I want to do subtraction between both closed date and created date column and have the result formatted as datetime itself. This is my code:

import datetime

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

dataframe = pd.read_csv('311_Service_Requests_from_2010_to_Present.csv') #import of dataset

dataframe['Request_Closing_Time']= dataframe['Closed Date'].values-dataframe['Created Date'].values

print(dataframe['Request_Closing_Time'])

It raises this kind of error:

unsupported operand type(s) for -: 'str' and 'str'

This is an example of the kind of datetime format contained on both columns:

12/31/2015 11:59:45 PM
0 Answers
Related