Pandas dataframe creation from a list
<p>Im getting the following error <code>Shape of passed values is (1, 5), indices imply (5, 5)</code>. From what I can tell this suggests that the data set doesnt match the column count, and of course it obviously is correct. Initially I thought it could be due to using a list, but I get the same issue if passing in a numpy array.</p>

<p>Can anyone point out my stupidity, as im clearly doing something incorrectly.</p>

<pre><code>data = ['data1', 'data2', 'data3', 'data4', 'data5']
report_name = 'test.csv'
try:
    df = pd.DataFrame(data, columns=['column1', 'column2', 'column3', 'column4', 'column5'], index=None)
    df.sort_values('column1', ascending=True, inplace=True)
    df.to_csv(report_name, index=False)
except Exception, e:
    print e
</code></pre>

<p>you have to pass a 2d dimensional array to <code>pd.DataFrame</code> for the data if you force the shape by passing <code>columns</code></p>

<pre><code>data = [['data1', 'data2', 'data3', 'data4', 'data5']]
df = pd.DataFrame(data, columns=['column1', 'column2', 'column3', 'column4', 'column5'])
</code></pre>

python pandas