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
  • 8,217
  • 4
  • 52
  • 75
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]

know more about stride-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.