title: Numpy Python: Exception: Data must be 1-dimensional
body: <p>Getting exception  <code>Exception: Data must be 1-dimensional</code></p>
  <p>using NumPy in Python 3.7</p>
  <p>Same code is working for others but not in my case. Bellow is my code please help</p>
  <blockquote>
  <p><a href="https://i.stack.imgur.com/6XBq8.jpg" rel="nofollow noreferrer">Working_code_in_diff_system</a></p>
  <p><a href="https://i.stack.imgur.com/Mw3r6.jpg" rel="nofollow noreferrer">Same_code_not_working_in_my_system</a></p>
  </blockquote>
  <pre><code>import numpy as np 
  from sklearn import linear_model
  from sklearn.model_selection import train_test_split
  import seaborn as sns
  from sklearn import metrics
  import matplotlib.pyplot as plt
  %matplotlib inline
  
  df = pd.read_csv('./Data/new-data.csv', index_col=False)
  
  x_train, x_test, y_train, y_test = train_test_split(df['Hours'], df['Marks'], test_size=0.2, random_state=42)
  
  sns.jointplot(x=df['Hours'], y=df['Marks'], data=df, kind='reg')
  
  x_train = np.reshape(x_train, (-1,1))
  x_test = np.reshape(x_test, (-1,1))
  y_train = np.reshape(y_train, (-1,1))
  y_test = np.reshape(y_test, (-1,1))
  
  
  
  #
  print('Train - Predictors shape', x_train.shape)
  print('Test - Predictors shape', x_test.shape)
  print('Train - Target shape', y_train.shape)
  print('Test - Target shape', y_test.shape)
  
  </code></pre>
  <p>Expected output should be</p>
  <blockquote>
  <p>Train - Predictors shape (80, 1)</p>
  <p>Test - Predictors shape (20, 1)</p>
  <p>Train - Target shape (80, 1)</p>
  <p>Test - Target shape (20, 1)</p>
  </blockquote>
  <p>As output getting exception <code>Exception: Data must be 1-dimensional</code></p>