Code Sample, a copy-pastable example if possible

index = np.linspace(-3, 5, 7)
df = pd.DataFrame({'A': np.sin(index), 'B': np.cos(index**2)}, index=index)
df.drop(columns=['A'])

Problem description

The docs say that I can use the columns keyword, but when I try I get the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-139-3a18b0426444> in <module>()
      2 df = pd.DataFrame({'A': np.sin(index), 'B': np.cos(index**2)}, index=index)
      3 # type(df.apply(np.sum, axis=1, reduce=False))
----> 4 df.drop(columns=['A'])

TypeError: drop() got an unexpected keyword argument 'columns'

The following is a workaround:

df.drop('A', axis=1)

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.6.2.final.0 python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None pandas: 0.20.3 pytest: 3.2.1 pip: 9.0.1 setuptools: 36.5.0.post20170921 Cython: 0.26.1 numpy: 1.13.1 scipy: 0.19.1 xarray: None IPython: 6.1.0 sphinx: 1.6.3 patsy: 0.4.1 dateutil: 2.6.1 pytz: 2017.2 blosc: None bottleneck: 1.2.1 tables: 3.4.2 numexpr: 2.6.2 feather: None matplotlib: 2.0.2 openpyxl: 2.4.8 xlrd: 1.1.0 xlwt: 1.3.0 xlsxwriter: 0.9.8 lxml: 3.8.0 bs4: 4.6.0 html5lib: 0.999999999 sqlalchemy: 1.1.13 pymysql: None psycopg2: None jinja2: 2.9.6 s3fs: None pandas_gbq: None pandas_datareader: None

Comment From: TomAugspurger

The index / columns keywords were added in 0.21 (there's a little note about that just below those keywords in the parameters list).

Comment From: anuzis

Getting this error in pandas 0.24.0.

I have a working pandas script that runs fine on 0.23.4. I needed to make a new virtualenv with TensorFlow GPU support via conda and it automatically installed a newer version of pandas (0.24.0), however, the newer version isn't backward compatible using columns as a keyword argument for dropping in a dataframe.

Comment From: TomAugspurger

Can you make a new issue with a reproducible example?

On Thu, Jan 31, 2019 at 11:20 AM Michael Anuzis notifications@github.com wrote:

Getting this error in pandas 0.24.0.

I have a working pandas script that runs fine on 0.23.4. I needed to make a new virtualenv with TensorFlow GPU support via conda and it automatically installed a newer version of pandas (0.24.0), however, the newer version isn't backward compatible using columns as a keyword argument for dropping in a dataframe.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/pandas-dev/pandas/issues/19078#issuecomment-459429497, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQHIp8Xr0Gw7HO5ti2-r9hKtbiGTxyzks5vIyX4gaJpZM4RTCbB .

Comment From: anuzis

Sure.

Edit: My mistake. Running 'pip freeze|grep pandas' from the conda virtualenv shows version 0.24.0, but running pd.show_versions() shows version 0.19.2... Haven't seen pip freeze show an incorrect mapping to a library version before...

'conda update pandas' shows it's 0.24.0, but somehow the conda virtualenv fails to use that version... I'll figure this out as it seems to be a non-pandas issue. Apologies for the mixup.

Edit2: If anyone else runs into the same issue the fix was running 'hash -r' from command line. ref: https://github.com/ipython/ipython/issues/10986

Comment From: DevinCharles

I'm running into this issue, on 0.24.2

INSTALLED VERSIONS

commit: None python: 3.7.2.final.0 python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: AMD64 Family 23 Model 1 Stepping 1, AuthenticAMD byteorder: little LC_ALL: None LANG: None LOCALE: None.None

pandas: 0.24.2

Comment From: DevinCharles

Hmmm... just realizing this is only happening on a multi-indexed df. Is there alternate syntax for that?

Comment From: TomAugspurger

@DevinCharles you can use a tuple

In [20]: df = pd.DataFrame({("A", 1): [1, 2], ("A", 2): [3, 4]})

In [21]: df.drop(columns=('A', 1))
Out[21]:
   A
   2
0  3
1  4

If you think there's still a bug, open a new issue, since this one has been closed.