Indexing in python dataframe using iloc to select all columns except the first column

Question:

I am trying to select all columns in a pandas dataframe in python except the first column using iloc.

I am able to select all column except the last one using the code

Pre_Processed.iloc[:,0:-1]

Could anyone please help me with this?

Asked By: Harsh

||

Answers:

Try this

Pre_Processed.iloc[:,1:]

Index with iterable works like

iterable[start:end:stride]

Read more about stride in

https://www.digitalocean.com/community/tutorials/how-to-index-and-slice-strings-in-python-3#:~:text=The%20third%20parameter%20specifies%20the,two%20index%20numbers%20is%20retrieved.

Answered By: shashank shekhar