yourdf.drop(['columnheading1', 'columnheading2'], axis=1, inplace=True)
dataframe.drop(['columnname1', 'columnname2'], axis=1, inplace=True)
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)
Code Example |
---|
Python :: streamlit install |
:: |
:: |
Python :: graph a line from dataframe values over a bar plot in python |
:: |
Python :: python - how many letters are capital in a string |
Python :: python substring from end |
:: |
Python :: |
:: |
:: |
Python :: |
Python :: get file in file zip python |
Python :: if-else |
Python :: find element in list that matches a condition |
:: z score formula in pandas |
Python :: |
:: str replace pandas |
:: python if type dict |
Python :: pretty printing using rich library in python |
:: |
:: |
:: ram clear in python |
Python :: |
Python :: |
Python :: |
Python :: |
Python :: pandas description of dataframe renaming column values |
Python :: check if string equals string in list python |
Python :: |