Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

drop multiple columns pandas

yourdf.drop(['columnheading1', 'columnheading2'], axis=1, inplace=True)
Comment

drop multiple columns in python

dataframe.drop(['columnname1', 'columnname2'], axis=1, inplace=True)
Comment

Drop multiple columns by name

import pandas as pd

# create a sample dataframe
data = {
    'A': ['a1', 'a2', 'a3'],
    'B': ['b1', 'b2', 'b3'],
    'C': ['c1', 'c2', 'c3'],
    'D': ['d1', 'd2', 'd3']
}

df = pd.DataFrame(data)

# print the dataframe
print("Original Dataframe:
")
print(df)

# remove columns C and D
df = df.drop(['C', 'D'], axis=1)

print("
After dropping columns C and D:
")
print(df)
Comment

PREVIOUS NEXT
Code Example
Python :: pyqt5 set window icon 
Python :: python count number of zeros in a column 
Python :: zip list to dictionary python 
Python :: selenium python get innerhtml 
Python :: python write to json with indent 
Python :: linux ubuntu install python 3.7 
Python :: how to put a text file into a list python 
Python :: python auto clicker 
Python :: autoslugfield django 3 
Python :: get file name from url python 
Python :: python open each file in directory 
Python :: python 2.7 ubuntu command 
Python :: install python 3.9 ubuntu 
Python :: sorting rows and columns in pandas 
Python :: django model plural 
Python :: python error get line 
Python :: image in cv2 
Python :: convert pdf to base64 python 
Python :: keyerror dislike_count pafy 
Python :: how to open an external file in python 
Python :: python get newest file in directory 
Python :: python requests get title 
Python :: python requirments.txt 
Python :: pyyaml install 
Python :: python remove empty string from list 
Python :: python random randint except a number 
Python :: django queryset group by count 
Python :: tkinter image 
Python :: python word cloud 
Python :: bmi python 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =