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,260 points
1,146 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,460 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,770 points
978 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
10,849 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
1,286 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,861 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,434 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,460 points
40,754 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
147,371 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,460 points
1,029 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