To drop the first column from the Pandas DataFrame use either iloc[]
property, drop()
, pop()
functions, and del
keyword. In this article, I will explain how to drop/delete/remove the first column from Pandas DataFrame with examples.
drop()
function is used to drop columns or drop rows from DataFrame;- Use
axis
param to specify what axis you would like to delete. By defaultaxis=0
meaning to remove rows. Useaxis=1
or columns param to remove columns. - Use
inplace=True
to remove row/column in place meaning on existing DataFrame without creating a copy.
Related: In Pandas, you can drop the first/last n columns from DataFrame.
1. Quick Examples of Drop First Column From DataFrame
If you are in a hurry, below are some quick examples of how to drop/delete the first column from DataFrame.
# Below are the quick examples
# Example 1: Drop first column of dataframe
# Using iloc[]
df2 = df.iloc[: , 1:]
# Example 2: select all columns
# Except the first column
df2 = df[df.columns[1:]]
# Example 3: Drop first column of dataframe
# Using drop()
df.drop(columns=df.columns[0], axis=1, inplace=True)
# Example 4: Using drop() function
# To delete first column
df2 = df.drop(df.columns[0],axis=1)
# Example 5: Use del keywords to drop
# First column of dataframe
del df[df.columns[0]]
# Example 6: Drop first column of dataframe
# Using pop()
df.pop(df.columns[0])
Now, Let’s create Pandas DataFrame using data from a Python dictionary, where the columns are Courses
, Fee
, Duration
and Discount
.
import pandas as pd
import numpy as np
technologies= ({
'Courses':["Spark","PySpark","Hadoop","Pandas"],
'Fee': [22000,25000,30000,35000],
'Duration':['30days','50days','40days','35days'],
'Discount':[1000,2000,2500,1500]
})
index_labels=['r1','r2','r3','r4']
df = pd.DataFrame(technologies,index=index_labels)
print("DataFrame:\n", df)
Yields below output.

2. Pandas Drop First Column of DataFrame Using iloc[]
You can use DataFrame.iloc[] with 1
as the input you can drop the first column from Pandas DataFrame, For example use, df.iloc[:,1:]
to select all columns except the first one and then assign it back to the original variable which ideally drops the first column from DataFrame.
# Drop first column of dataframe using iloc[]
# Using iloc[]
df2 = df.iloc[: , 1:]
print("After dropping the first column:\n", df2)
Yields below output.

3. Drop First Column of DataFrame Using drop()
You can also use DataFrame.drop() function to remove the first column. Use axis=1
to specify the columns and inplace=True
to apply the change on the existing DataFrame. In the below example, df.columns[0]
returns Courses which is the first column from our DataFrame.
# Drop first column of dataframe using drop()
df.drop(columns=df.columns[0], axis=1, inplace=True)
print("After dropping the first column:\n", df)
# Using drop() function to delete first column
df2 = df.drop(df.columns[0],axis=1)
print("After dropping the first column:\n", df2)
Yields the same output as above.
4. Use del Keyword to Drop the First Column
Alternatively, you can also use del df[df.columns[0]]
to remove the first column of the Pandas DataFrame. Here, it will select all columns except the first column of DataFrame.
# Use del keywords to drop
# First column of dataframe
del df[df.columns[0]]
print("After dropping the first column:\n", df)
Yields the same output as above.
5. Drop the First Column of DataFrame Using pop()
Similarly, you can use DataFrame.pop()
function to drop the first column of pandas DataFrame and also return the remove column as a series. So, you can select the first column of DataFrame by using df.columns[0]
and passing this to the pop(), it will select all columns except the first column of DataFrame.
Related: You can also drop the last column of the DataFrame.
# Drop first column of dataframe using pop()
df.pop(df.columns[0])
print("After dropping the first column:\n", df)
Yields the same output as above.
6. Complete Example For Drop First Column From DataFrame
import pandas as pd
import numpy as np
technologies= ({
'Courses':["Spark","PySpark","Hadoop","Pandas"],
'Fee': [22000,25000,30000,35000],
'Duration':['30days','50days','40days','35days'],
'Discount':[1000,2000,2500,1500]
})
index_labels=['r1','r2','r3','r4']
df = pd.DataFrame(technologies,index=index_labels)
print(df)
# Drop first column of dataframe using iloc[]
df2 = df.iloc[: , 1:]
print(df2)
# Select all columns
# Except the first column
df2 = df[df.columns[1:]]
print(df2)
# Drop first column of dataframe using drop()
df.drop(columns=df.columns[0], axis=1, inplace=True)
print(df)
# Using drop() function to delete first column
df2 = df.drop(df.columns[0],axis=1)
print(df2)
# Use del keywords to drop
# First column of dataframe
del df[df.columns[0]]
print(df)
# Drop first column of dataframe using pop()
df.pop(df.columns[0])
print(df)
Frequently Asked Questions on Drop First Column from Pandas DataFrame
To drop the first column from a DataFrame, you can use the drop()
method along with the column name and specify axis=1
to indicate that you are dropping a column. For example, df1 = df.drop(df.columns[0], axis=1)
You can use integer indexing to drop the first column without explicitly specifying the column name. For example, df1 = df.drop(df.columns[0], axis=1)
You can use the inplace=True
parameter to modify the existing DataFrame in place instead of creating a copy of the DataFrame. For example, df.drop(df.columns[0], axis=1, inplace=True)
If you want to drop multiple columns, including the first one, you can pass a list of column names to the drop()
method: For example, columns_to_drop = [df.columns[0], 'Column2', 'Column3']
df = df.drop(columns = columns_to_drop)
You can use the slicing technique to drop the first N columns from the DataFrame. For example,n = 3
df = df.iloc[:, n:]
7. Conclusion
In this article, I have explained how to drop the first column from Pandas DataFrame using DataFrame.iloc[]
, DataFrame.drop()
, and DataFrame.pop()
, and del
Keyword functions with examples.
Happy Learning !!
Related Articles
- Pandas Drop Rows by Index
- Pandas Delete Last Row From DataFrame
- Pandas Drop Last N Rows From DataFrame
- Pandas Drop First N Rows From DataFrame
- How to drop first row from the Pandas DataFrame
- Pandas – Drop First Three Rows From DataFrame
- Pandas Drop Multiple Columns From DataFrame
- How to Drop Duplicate Columns in Pandas DataFrame?
- How to drop the Pandas column by index?
- Pandas Drop Columns with NaN or None Values
- Drop multiple columns by index
- Pandas Series loc[] Function
- Pandas Difference Between loc[] vs iloc[]
- Pandas loc[] multiple conditions