Error 'Expected 2D array, got 1D array instead:' While performing a simple fitting operation on the Titanic dataset. The following is my code:

data = pd.read_csv(r'.\Desktop\DS\Titanic\train.csv')
sex_train = data['Sex'].map({'male':0,'female':1})
survived_train = data['Survived']
sex_survivor_tree = GaussianNB()
sex_survivor_tree.fit(sex_train,survived_train)
This is a bit tricky. Using pandas data, sklearn only accepts input variables (features) with type pandas.Dataframe. In your code variable sex_train in pandas.Series type. Try the following code :

sex_train = data['Sex'].map({'male':0,'female':1}).to_frame()