3

I have a dataframe called "tips" in which I am trying to drop two columns, tip and higher_than_15pct_true, as follows:

X = tips.drop('tip','higher_than_15pct_True', axis = 1)

This results in the following error:

TypeError: drop() got multiple values for argument 'axis'

How can I fix this?

0

2 Answers 2

8

According to the pandas documentation for DataFrame.drop, you need to pass either a single label, or a list if you have multiple columns:

X = tips.drop(['tip','higher_than_15pct_True'], axis = 1)

The TypeError unfortunately ends up being quite cryptic and unrelated to the real problem at hand.

Sign up to request clarification or add additional context in comments.

Comments

1

You forget the bracket. Or use this one

remove = ['tip','higher_than_15pct_True']
tips= df[df.columns.difference(remove)]

Thanks

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.