# I received this error message: Found input variables with inconsistent numbers of samples: [15573, 15600]. How do I resolve it please?

I received that error and when running my code, I realised that the issue lies with my X_train and y_train.

The link below is the source of my data (test.csv and train.csv)

My X_train.shape gave me (15573,) and my y_train gave me (15600,)

How do I reshape this?

• You cat reshap them, you have to figure why it's happening because y_train and X_train will have same shape by default Apr 8 '19 at 5:34
• @Aditya Strangely, my X_test and y_test tally...Is there a particular reason why it isn't the same for y_train and X_train? Apr 8 '19 at 5:54
• See if you are dropping some rows or not or else if they are one-to-one matching, then just reduce the X_train; Apr 8 '19 at 5:59
• @Aditya Got it, will give that a shot! To reduce the X_train, I inputted this code: y_train_new=y_train[1:17644] but it showed me an error. The aim is to make it the same as that of y_train Apr 8 '19 at 6:13
• 17644 isn't the y_train dims, it's 15600 but be careful, you shouldn't be using such tricks as in a normal scenario, this shouldn't happen actually. If you can share your preprocessing, folks can then help finding what's causing it unless it's by default like that Apr 8 '19 at 6:33

## 1 Answer

You likely get problems because you remove rows containing nulls in X_train and y_train independent of each other. y_train probably has few, or no nulls and X_train probably has some. So when you remove a row in X_train and the same row is not removed in y_train it will cause your data to be unsynced and have different lenghts. Instead you should remove nulls before you separate X and y.

Before this:

X = df['text']
y = df['label']


Do this:

df.dropna(inplace=True)


And remove this:

X_train.dropna(inplace=True)
X_test.dropna(inplace=True)
y_train.dropna(inplace=True)
y_test.dropna(inplace=True)

• That worked! Thank you :) Apr 9 '19 at 9:30