Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Drop Rows¶
import pandas as pd
data = {
"name": ["Jason", "Molly", "Tina", "Jake", "Amy"],
"year": [2012, 2012, 2013, 2014, 2014],
"reports": [4, 24, 31, 2, 3],
}
df = pd.DataFrame(data, index=["Cochice", "Pima", "Santa Cruz", "Maricopa", "Yuma"])
dfLoading...
df.drop(["Cochice", "Pima"])Loading...
Drop Columns¶
import pandas as pd
data = {
"name": ["Jason", "Molly", "Tina", "Jake", "Amy"],
"year": [2012, 2012, 2013, 2014, 2014],
"reports": [4, 24, 31, 2, 3],
}
df = pd.DataFrame(data, index=["Cochice", "Pima", "Santa Cruz", "Maricopa", "Yuma"])
dfLoading...
df.drop("reports", axis=1, inplace=False)Loading...
df.drop(df.columns[[0, 1]], axis=1)Loading...