Hi guys, i am trying to iterate columns on my csv file before training the dataset .Can anyone help out with how to use iteration or any other method to skip columns
I don't get your point well. Do you mean having the name of columns in a list which can probably be used in for loop?
df.columns would solve that
Or you mean selecting or dropping some particular columns before fitting it into a model
Yes exactly , dropping some columns before calling the fit on the dataset.
to_drop = ['form_field1', 'form_field10', 'form_field50', 'default_status'] #a list of columns you want to drop
X = df.drop(to_drop, axis=1) #the axis=1 specify that it should delete columns not row. so very important
If you don't want a new df and want to continue with normal df, add inplace=True e.g
df.drop(to_drop, axis=1, inplace=True)
You could use some list index slicing or just do a counter like df.columns which returns a list
for i in df.columns:
If condition is true:
Do some operation on the columns
I will try this now. Thanks