You can drop the column using the drop()
method in Pandas. Here is an example:
import pandas as pd
# create a sample dataframe
df = pd.DataFrame({
'A': [1, 2, 3],
'B': [4, 5, 6],
'C': [7, 8, 9]
})
# drop column 'C'
df = df.drop('C', axis=1)
# view the dataframe without column 'C'
print(df)
In this example, we are dropping the column 'C' using the drop()
method with the axis=1
parameter. The resulting dataframe will no longer have the 'C' column. You can replace 'C' with the name of the column that you want to drop in your own dataframe.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-03-13 11:00:00 +0000
Seen: 9 times
Last updated: Jun 17 '21
How can I include the hours component to a DateTime column using PowerQuery?
Identify commonalities among the strings in a specific column of a DataFrame.
What is the procedure for using Pandas fillna() method with the column's mode?
How can you use linq to choose a specific column from a datatable?