title: Converting object datatype to datetime datatype in Python using pandas
body: <p>I have a dataset of Cab Fare Prediction and I need to convert one of its variable &quot;pickup_datetime&quot; to datetime datatype from object datatype. I am using pandas to convert it to datetime. Code:</p>
  <pre><code>data['pickup_datetime']=pd.to_datetime(data['pickup_datetime'],format='%Y-%m-%d %H:%M:%S UTC')
  </code></pre>
  <p>I am getting below error. Can someone suggest how to find the incorrect row from my variable?</p>
  <pre><code>&gt; TypeError                                 Traceback (most recent call last)
  &gt; ~\Anaconda3\lib\site-packages\pandas\core\tools\datetimes.py in
  &gt; _convert_listlike_datetimes(arg, box, format, name, tz, unit, errors, infer_datetime_format, dayfirst, yearfirst, exact)
  &gt;     290             try:
  &gt; --&gt; 291                 values, tz = conversion.datetime_to_datetime64(arg)
  &gt;     292                 return DatetimeIndex._simple_new(values, name=name, tz=tz)
  &gt; 
  &gt; pandas/_libs/tslibs/conversion.pyx in
  &gt; pandas._libs.tslibs.conversion.datetime_to_datetime64()
  &gt; 
  &gt; TypeError: Unrecognized value type: &lt;class 'str'&gt;
  &gt; 
  &gt; During handling of the above exception, another exception occurred:
  &gt; 
  &gt; ValueError                                Traceback (most recent call
  &gt; last) &lt;ipython-input-59-c94549aa5074&gt; in &lt;module&gt;
  &gt; ----&gt; 1 data['pickup_datetime']=pd.to_datetime(data['pickup_datetime'],format='%Y-%m-%d
  &gt; %H:%M:%S UTC')
  &gt; 
  &gt; ~\Anaconda3\lib\site-packages\pandas\core\tools\datetimes.py in
  &gt; to_datetime(arg, errors, dayfirst, yearfirst, utc, box, format, exact,
  &gt; unit, infer_datetime_format, origin, cache)
  &gt;     590         else:
  &gt;     591             from pandas import Series
  &gt; --&gt; 592             values = convert_listlike(arg._values, True, format)
  &gt;     593             result = Series(values, index=arg.index, name=arg.name)
  &gt;     594     elif isinstance(arg, (ABCDataFrame, compat.MutableMapping)):
  &gt; 
  &gt; ~\Anaconda3\lib\site-packages\pandas\core\tools\datetimes.py in
  &gt; _convert_listlike_datetimes(arg, box, format, name, tz, unit, errors, infer_datetime_format, dayfirst, yearfirst, exact)
  &gt;     292                 return DatetimeIndex._simple_new(values, name=name, tz=tz)
  &gt;     293             except (ValueError, TypeError):
  &gt; --&gt; 294                 raise e
  &gt;     295 
  &gt;     296     if result is None:
  &gt; 
  &gt; ~\Anaconda3\lib\site-packages\pandas\core\tools\datetimes.py in
  &gt; _convert_listlike_datetimes(arg, box, format, name, tz, unit, errors, infer_datetime_format, dayfirst, yearfirst, exact)
  &gt;     259                 try:
  &gt;     260                     result, timezones = array_strptime(
  &gt; --&gt; 261                         arg, format, exact=exact, errors=errors)
  &gt;     262                     if '%Z' in format or '%z' in format:
  &gt;     263                         return _return_parsed_timezone_results(
  &gt; 
  &gt; pandas/_libs/tslibs/strptime.pyx in
  &gt; pandas._libs.tslibs.strptime.array_strptime()
  &gt; 
  &gt; ValueError: time data '43' does not match format '%Y-%m-%d %H:%M:%S
  &gt; UTC' (match)
  </code></pre>