When deleting a column in a DataFrame I use:
del df[\'column_name\']
And this works great. Why can\'t I use the following?
Deleting a column using iloc
function of dataframe
and slicing
, when we have a typical column name with unwanted values.
df = df.iloc[:,1:] # removing an unnamed index column
Here 0
is the default row and 1
is 1st column so ,1
where starts and stepping is taking default values, hence :,1:
is our parameter for deleting the first column.