Ask Your Question
3

How can I eliminate a column in Pandas that is causing my tests to fail and appears to be abnormal?

asked 2022-03-13 11:00:00 +0000

bukephalos gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-06-17 17:00:00 +0000

scrum gravatar image

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.

edit flag offensive delete link more

Your Answer

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

Add Answer


Question Tools

Stats

Asked: 2022-03-13 11:00:00 +0000

Seen: 9 times

Last updated: Jun 17 '21