'Expected 2D array, got 1D array instead even though it is already in 2d

I'm trying to predict a new result

sc_y.inverse_transform(regressor.predict(sc_X.transform([[6.5]])))

After running the code it shows this error

ValueError: Expected 2D array, got 1D array instead: array=[-0.27861589]. Reshape your data either using an array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source