0

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?

Bill
  • 10,323
  • 10
  • 62
  • 85
Harsh
  • 21
  • 5
  • Pre_Processed.iloc[:, 1:] ... google indexing in python.... you index like - iterable[start:end:step] – Derek Eden Sep 11 '20 at 03:14
  • 1
    It's also called 'slicing'. Try [this answer](https://stackoverflow.com/questions/509211/understanding-slice-notation) – Bill Sep 11 '20 at 03:18

1 Answers1

0

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.

SiHa
  • 7,830
  • 13
  • 34
  • 43