title: Python: How do I show list with > 1 variable as separate columns in pandas.DataFrame?
body: <p>I am new to python and I am using pandas to present some data.</p>
  
  <p>1) My <code>x_test</code> variable is a list with 2 variables, and I want to present both variables in separate columns in the data frame. I used the below code, but I get <code>ValueError: arrays must all be same length</code>.</p>
  
  <pre><code>'x': x_test[1].flatten(),
  '2x': x_test[2].flatten(),
  </code></pre>
  
  <p>2) How do I restrict to 2 decimal places for "Prediction Diff" column in my data frame?</p>
  
  <p>3) I tried sorting my data frame by "Prediction Diff" column, but it is not correctly sorted.</p>
  
  <p>The whole code is following.</p>
  
  <pre><code>import pandas as pd
  x_test = list()
  x_test = test_data[[input_param_name, input2_param_name]].values
  
  test_predictions_table = pd.DataFrame({
      'x': x_test[1].flatten(),
      '2x': x_test[2].flatten(),
      'y': y_test.flatten(),
      'Predicted y': test_predictions.flatten(),
      'Prediction Diff': (y_test - test_predictions).flatten()
  })
  
  test_predictions_table.sort_values(by='Prediction Diff')
  print(test_predictions_table)
  </code></pre>