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 :: schedule asyncio python 
Python :: remove whitespace in keys from dictionary 
Python :: python download file from web 
Python :: run python script from c# 
Python :: download image python 
Python :: fastest sort python 
Python :: python get the key with the max or min value in a dictionary 
Python :: display result in same page using flask api 
Python :: python draw polygon 
Python :: python define 2d table 
Python :: codeforces 677a python solution 
Python :: fill na with mode and mean python 
Python :: count unique values in pandas column 
Python :: python deepcopy 
Python :: plotly hide trace from hover 
Python :: debugar python 
Python :: pyautogui pause in python 
Python :: pandas dataframe print decimal places 
Python :: how to add up everything in a list python 
Python :: python udp receive 
Python :: get first element list of tuples python 
Python :: hot reloading flask 
Python :: sort by dataframe 
Python :: how to delete records in pandas before a certain date 
Python :: how to display a manytomany field in django rest framework 
Python :: python import ndjson data 
Python :: python tkinter quit button 
Python :: add font to the label in window tkinter 
Python :: pipenv 
Python :: import statsmodels.api as sm 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =