Learn.
In this section we will learn how to split feature and target variables
# separating features and target
X = df.drop(“price”,axis=1)
y = df[[“price”]]
# display the features (input variables)
X
# getting dummies and dropping first
X_dummy = pd.get_dummies(X,drop_first=True)
# display dummy features
X_dummy
# Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X_dummy, y, test_size=0.2, random_state=42)
# display X_train and y_train data
print(X_train.head())
print(y_train.head())
print(y_train.head())