title: Can you use datetime.strptime without knowing the format?
body: <p>I am writing a function that takes 3 pandas Series, one of which is dates, and I need to be able to turn it into a dataframe where I can resample by them. The issue, is that when I simply do the following:</p>
  
  <pre><code>&gt;&gt;&gt; data.index = data.time
  &gt;&gt;&gt; df = data.resample('M')
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/generic.py", line 234, in resample
      return sampler.resample(self)
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/tseries/resample.py", line 100, in resample
      raise TypeError('Only valid with DatetimeIndex or PeriodIndex')
  TypeError: Only valid with DatetimeIndex or PeriodIndex
  </code></pre>
  
  <p>I know this is because even though the index type is a datetime object, when going through with resampling, unless it is in the form <code>datetime(x,x,x,x,x,x)</code>, It wont read it correctly. </p>
  
  <p>So when I use it, my date data looks like this: <code>2011-12-16 08:09:07</code>, so I have been doing the following:</p>
  
  <pre><code>dates = data.time
  date_objects = [datetime.strptime(dates[x], '%Y-%m-%d %H:%M:%S') for x in range(len(dates))]
  data.index = date_objects 
  df = data.resample('M')
  </code></pre>
  
  <p>My issue is that I am using this for open source and I cannot know what format the dates will be when inputted. </p>
  
  <p><strong>So my question is: how can I turn a string with a date and a time to a datetime object WITHOUT knowing the way that string is formatted?</strong> </p>