conversion of np.array(dtype='str') in an np.array(dtype='datetime')
<p>I have a very simple python question. I need to transform the string values within an np.array into datetime values. The string values contain the following format: ('%Y%m%d'). Does any one know how to this? 
Here my test data:</p>

<pre><code>date_str = np.array([['20121002', '20121002', '20121002'],
                     ['20121003', '20121003', '20121003'],
                     ['20121004', '20121004', '20121004']])
</code></pre>

<p>I try to convert this array with the pandas library.
Here is my code:</p>

<pre><code>import pandas as pd    
pd.to_datetime(date_str, format="%d%m%Y")
</code></pre>

<p>Please help me there should be a very simple way to convert this and note that I'm a python beginner.</p>

<p>Convert each element of the array to a <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.html" rel="nofollow">pandas series</a>, and perform the <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.to_datetime.html" rel="nofollow">to_datetime()</a> operation.</p>

<pre><code>In [81]: [pd.to_datetime(pd.Series(x), format="%Y%m%d") for x in date_str]
Out[81]: 
[0   2012-10-02
 1   2012-10-02
 2   2012-10-02
 dtype: datetime64[ns], 0   2012-10-03
 1   2012-10-03
 2   2012-10-03
 dtype: datetime64[ns], 0   2012-10-04
 1   2012-10-04
 2   2012-10-04
 dtype: datetime64[ns]]
</code></pre>

python datetime pandas numpy