Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Dropping columns in Pandas

# Dropping a single column
df = pd.DataFrame({"A":[3,4], "B":[5,6], "C":[7,8]})
df_new = df.drop(columns="B")

# Dropping multiple columns
df_new = df.drop(columns=["A","B"])

# Dropping columns in-place
df.drop(columns="B", inplace=True)
Source by skytowner.com #
 
PREVIOUS NEXT
Tagged: #Dropping #columns #Pandas
ADD COMMENT
Topic
Name
4+9 =