-2
X = df_census.iloc[:,:-1]
y = df_census.iloc[:,-1]

what is the meaning of [:,:-1] in this and also [:,-1]

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57

1 Answers1

0

Following your example: [:,:-1]

The first argument is : which means to get all rows of the dataframe, and :-1 means to return all columns but the last one

In the case of just -1, it means to get the last column

datasor
  • 31
  • 2