Hey can anybody tell me what is the meaning of this?

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

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

1 Answers

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

Related