dtypes changed when initialising a new DataFrame from another one
<p>Let's say that I have a DataFrame df1 with 2 columns: <code>a</code> with dtype <code>bool</code> and <code>b</code> with dtype <code>int64</code>. When I initialise a new DataFrame (<code>df1_bis</code>) from <code>df1</code>, columns <code>a</code> and <code>b</code> are automatically converted into objects, even if I force the dtype of <code>df1_bis</code>:</p>

<pre><code>In [2]: df1 = pd.DataFrame({"a": [True], 'b': [0]})
Out[3]:
      a  b
0  True  0

In [4]: df1.dtypes
Out[4]:
a     bool
b    int64
dtype: object

In [5]: df1_bis = pd.DataFrame(df1.values, columns=df1.columns,     dtype=df1.dtypes)
Out[6]:
      a  b
0  True  0

In [7]: df1_bis.dtypes
Out[7]:
a    object
b    object
dtype: object
</code></pre>

<p>Is there something I'm doing wrong with the <code>dtype</code> argument of DataFrame? </p>

<p>It is <code>numpy</code> that is causing the problem.  <code>pandas</code> is inferring the types from the numpy array.  If you convert to a list, you won't have the problem.</p>

<pre><code>df1_bis = pd.DataFrame(df1.values.tolist(),
                       columns=df1.columns)


print(df1_bis)
print
print(df1_bis.dtypes)

      a  b
0  True  0

a     bool
b    int64
dtype: object
</code></pre>

python pandas dataframe casting multiple-columns