The method knn.fit(X, y) takes two parameters, X and y. X is the training data and y is the target column. The training data can be in the form of one or various columns of a DataFrame.
X = [col_a, col_b, col_n]
# Here, we are training our model on various columns of our data
X = [col_a]
# Here, we are using only one column, i.e. this is a univariate case.
# The brackets are still there, because it's a list - even if we're
# left with only one element
When you have questions like this, it is always a good idea to take a look at the documentation
for multiple features i use this format knn.fit(df[['feature_column_1','feature_column_2']], train_target)
i use as an input a dataframe
so i expect that for 1 feature the logical would be to input a series? knn.fit(df['feature_column_1'], train_target) ?
This paper tells you how sklearn is designed. It’s not academic so should be readable for anyone.
If i remember right, all models (not only knn) in sklearn requires 2-D input to fit, predict, transform. In your case, indexing a dataframe with single column will return series, a 1-D object, so you must index using double [] to return dataframe (even if contains only 1 column).