Train test split

I also done this

X = inputs[numeric_cols + encoded_cols]
X_test = test_inputs[numeric_cols + encoded_cols]

But when I am doing train_test_split below error showing

Code : train_inputs, val_inputs, train_targets, val_targets = train_test_split(inputs[numeric_cols + encoded_cols], targets, test_size=0.25,random_state=42 )

KeyError Traceback (most recent call last)
in ()
----> 1 train_inputs, val_inputs, train_targets, val_targets = train_test_split(inputs[numeric_cols + encoded_cols], targets, test_size=0.25,random_state=42 )

2 frames
/usr/local/lib/python3.7/dist-packages/pandas/core/indexing.py in _validate_read_indexer(self, key, indexer, axis, raise_missing)
1302 if raise_missing:
1303 not_found = list(set(key) - set(ax))
→ 1304 raise KeyError(f"{not_found} not in index")
1305
1306 # we skip the warning on Categorical

KeyError: '[‘Name_Bartra’, ‘Name_P. Hoffmann’, ‘Name_D. Cole’, ‘Name_T. Hopper’, ‘Name_Amilton’, ‘Name_Jonas’, ‘Name_A. Cossu’, ‘Name_I. Wadji’, ‘Name_E. Sağlik’, ‘Name_Onwu’, ‘Name_Calero’, ‘Name_S. Nolan’, ‘Name_Diego Medeiros’, ‘Name_D. Skhirtladze’, ‘Name_B. Dibassy’, ‘Name_C. Bramall’, ‘Name_B. Jayiya’, ‘Name_E. Ardenaz’, ‘Name_S. Yıldırım’, ‘Name_A. Trajkovski’, ‘Name_J. Bitter’, ‘Name_A. Lizañas’, ‘Name_M. Niemeyer’, ‘Name_H. Özkan’, ‘Name_C. Rúa’, ‘Name_Ahn Joon Soo’, ‘Name_J. Hoekstra’, ‘Name_F. Boeckx’, ‘Name_S. Maholli’, ‘Name_R. Neustädter’, ‘Name_N. Erlbeck’, ‘Name_J. Wójcicki’, ‘Name_D. Ceter’, ‘Name_Danilo Avelar’, ‘Name_A. Uryga’, ‘Name_Lee Chang Min’, ‘Name_L. Melano’, ‘Name_L. Krogh Gerson’, ‘Name_D. Smith’, ‘Name_M. Christiansen’, ‘Name_D. Jardine’, ‘Name_Jou Silva’, ‘Name_P. Jaroszyński’, ‘Name_B. Başdaş’, ‘Name_F. Sucsuz’, ‘Name_S. Delev’, ‘Name_I. Pelizzoli’, ‘Name_D. Orgill’, ‘Name_F. Kent’, ‘Name_C. Immobile’, ‘Name_B. Pedretti’, ‘Name_E. Berisha’, ‘Name_R. Živković’, ‘Name_L. Angulo’, ‘Name_J. Gjasula’, ‘Name_J. Tamimi’, ‘Name_S. Palla’, ‘Name_L. Pionnier’, ‘Name_A. Rüdiger’, ‘Name_Lee Jin Hyun’, ‘Name_O. Hansen’, ‘Name_R. Oudin’, ‘Name_M. Harriman’, ‘Name_J. Johansen’, ‘Name_D. Higgins’, ‘Name_W. Nightingale’, ‘Name_O. Hein’, ‘Name_B. Fuller’, ‘Name_D. Luckassen’, ‘Name_C. Martinez’, 'Name_A. Tamba…

i don’t know what the error is but can you print the shape of inputs and targets? inputs and targets need to have the same number of rows.

eg.
train_inputs.shape : (867, 3594)
train_targets.shape : (867,)
val_inputs.shape : (290, 3594)
val_targets.shape : (290,)

Thank you for your reply, but my question is when I am having train & test data sets and I am implementing ( train_inputs, val_inputs, train_targets, val_targets = train_test_split(inputs[numeric_cols + encoded_cols], targets, test_size=0.25,random_state=42 ) this code, then i am getting above mentioned error

convert pandas to numpy
maybe this link can help you: