Drop Rows¶
In [1]:
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"])
df
Out[1]:
In [2]:
df.drop(["Cochice", "Pima"])
Out[2]:
Drop Columns¶
In [3]:
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"])
df
Out[3]:
In [4]:
df.drop("reports", axis=1, inplace=False)
Out[4]:
In [5]:
df.drop(df.columns[[0, 1]], axis=1)
Out[5]:
In [ ]: