how to prepare independent and dependent variables from dataframe

# Independent variables
X = df.iloc[:, :-1].values

# dependent variable y
y = df.iloc[:,-1].values

Here is what the above code is Doing:
1. Importing the dataset
2. Splitting the dataset into the Training set and Test set
3. Feature Scaling
4. Fitting Simple Linear Regression to the Training set
5. Predicting the Test set results
6. Visualising the Training set results
7. Visualising the Test set results