How to delete column from pandas DataFrame

0 votes

Hi Guys,

I have one DataFrame in Pandas. I want to delete one column from this DataFrame. How can I do that? 

Jun 24, 2020 in Python by akhtar
• 38,120 points
163 views

1 answer to this question.

0 votes

Hi@akhtar,

You can use the del command in Pandas to delete one column from your DataFrame. I have attached one example below for your reference.

import pandas as pd
df = pd.read_csv('my.csv')
Place State
0 Kolkata WestBengal
1 Delhi Delhi
2 Bangalore Karnataka
3 Kolkata WestBengal
4 Delhi Delhi
del df['Place']
State
0 WestBengal
1 Delhi
2 Karnataka
3 WestBengal
4 Delhi

I hope this will help you.

answered Jun 24, 2020 by MD
• 94,990 points

Related Questions In Python

0 votes
1 answer

How to get list from pandas DataFrame column headers?

You can get the values as a ...READ MORE

answered Dec 23, 2020 in Python by Gitika
• 65,850 points
45 views
0 votes
1 answer

How to create empty pandas dataframe only with column names?

You can do it like this: df=pd.DataFrame(columns=["Name","Old","Ne ...READ MORE

answered Apr 5, 2019 in Python by Hari
5,717 views
0 votes
1 answer

How to create Pandas dataframe from Python list?

You can do it like this: import ...READ MORE

answered Apr 5, 2019 in Python by Likhita
481 views
0 votes
1 answer

How to replace entire column in pandas dataframe?

Use the dataframe with respective column names ...READ MORE

answered May 8, 2019 in Python by John
5,935 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,740 views
0 votes
0 answers
0 votes
1 answer

KeyError: "['Place'] not found in axis"

Hi@akhtar, You need to provide the axis parameter ...READ MORE

answered Jun 24, 2020 in Python by MD
• 94,990 points
10,318 views
+1 vote
3 answers

How to change/update cell value in Python Pandas dataframe?

You can use the at() method to ...READ MORE

answered Apr 8, 2019 in Python by Kunal
97,040 views
0 votes
1 answer

How to merge two DataFrame in Pandas?

Hi@akhtar, You can use Pandas.merge() function to merge ...READ MORE

answered Jun 22, 2020 in Python by MD
• 94,990 points
111 views