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 :: user information in python 
Python :: streamlit install 
Python :: django queryset count 
Python :: Write a table to CSV file python 
Python :: hashing in python using chaining in python 
Python :: binary gap python 
Python :: CSV data source does not support array<string data type 
Python :: python string cut right 
Python :: change forms labels django 
Python :: import path in django 
Python :: python save button 
Python :: Format UTC to local timezone using PYTZ for Django 
Python :: python 2.7 datetime to timestamp 
Python :: use map in python to take input 
Python :: scikit learn roc curve 
Python :: overriding update in serializer django 
Python :: python repet x time 
Python :: Invalid password format or unknown hashing algorithm. 
Python :: python using re trimming white space 
Python :: try python 
Python :: python node class 
Python :: Invalid comparison between dtype=datetime64[ns] and date filter 
Python :: hungry chef 
Python :: read part of file pandas 
Python :: turn columns into one column as list python 
Python :: python3 check if object has attribute 
Python :: deleting a file using python 
Python :: raw query in django 
Python :: make virtual environment wrapper python 3 
Python :: numpy generate sequence 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =