Numpy reshape issues
<pre><code>import numpy as np
import matplotlib.pyplot as plt
from matplotlib import style
from sklearn.linear_model import LinearRegression
from sklearn import preprocessing, cross_validation, svm


df = pd.read_csv('table.csv') 
print (df.head())

df = df[['Price', 'Asset']]
x = np.array(df.Price)
y = np.array(df.Asset)

x_train, x_test, y_train, y_test = cross_validation.train_test_split(
x, y, test_size=0.2)


x_train = np.pad(x, [(0,0)], mode='constant')
x_train.reshape((23,1))


y_train = np.pad(y, [(0,0)], mode ='constant')
y_train.reshape((23,1))

np.reshape(-1, 1)
</code></pre>

<p>Error:</p>

<pre><code>runfile('C:/Users/HP/Documents/linear.py', wdir='C:/Users/HP/Documents')
       Price     Asset
0    87.585859    191
1    87.839996    232
2    87.309998    245
3    88.629997    445
4    88.379997    393
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\utils\validation.py:386: 

    DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and willraise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample.
  DeprecationWarning)
Traceback (most recent call last):

  File "&lt;ipython-input-124-030ffa933525&gt;", line 1, in &lt;module&gt;
    runfile('C:/Users/HP/Documents/linear.py', wdir='C:/Users/HP/Documents')

  File "C:\Users\HP\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 714, in runfile
    execfile(filename, namespace)

  File "C:\Users\HP\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 89, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/HP/Documents/linear.py", line 38, in &lt;module&gt;
    clf.fit(x_train, y_train)

  File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\linear_model\base.py", line 427, in fit
    y_numeric=True, multi_output=True)

  File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 520, in check_X_y
    check_consistent_length(X, y)

  File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 176, in check_consistent_length
    "%s" % str(uniques))

ValueError: Found arrays with inconsistent numbers of samples: [ 1 23]
</code></pre>

<p>My DataFrame size: 23, 2. </p>

<p>I padded my x_train and y_train to [23,1] because i  got this initial error <strong>ValueError</strong>: Found arrays with inconsistent numbers of samples: [1 18].
My error message after padding: <strong>ValueError</strong>: Found arrays with inconsistent numbers of samples: [ 1 23].  </p>

<p>Then i tried to reshape it and still got the error message: <strong>ValueError</strong>: Found arrays with inconsistent numbers of samples: [ 1 23].  </p>

<p>How do i fix this?</p>

<p>If you only want to reshape an array from size <code>(x, 1)</code> to <code>(1, x)</code> you can use the <code>np.transpose</code> or <code>numpy.ndarray.T</code> function:</p>

<pre><code>x_train = x_train.T
y_train = np.transpose(y_train)
</code></pre>

<p>Both achieve the same result. </p>

<p>Edit: <em>This only works for one-dimensional arrays. Use reshape for higher dimensional arrays.</em></p>

<p>If you do not give us the full traceback which shows in which line the error occurs, we can't help you in more detail.</p>

python numpy