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,230 points
922 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
• 95,440 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,910 points
752 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 6, 2019 in Python by Hari
9,939 views
0 votes
1 answer

How to create Pandas dataframe from Python list?

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

answered Apr 6, 2019 in Python by Likhita
956 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
13,544 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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,069 views
0 votes
1 answer
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
• 95,440 points
40,028 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
146,558 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 23, 2020 in Python by MD
• 95,440 points
740 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP