Skip to content

df.squeeze() doesn't support axis parameter #15339

Closed
@kernc

Description

@kernc

Code Sample, a copy-pastable example if possible

>>> df = pd.DataFrame([1], columns=['A'])

>>> df 
   A
0  1

>>> df.squeeze()
1

>>> type(df.squeeze())
numpy.int64

>>> df.squeeze(axis=1)  # Only want to squeeze a single dimension, i.e. into a series
...
ValueError: the 'axis' parameter is not supported in the pandas implementation of squeeze()

Problem description

np.squeeze supports axis parameter and this comment in the source implies it should eventually be implemented.

Expected Output

>>> df.squeeze(axis=1)  # Squeeze a single dimension, i.e. into a series
0    1
Name: A, dtype: int64

>>> df.squeeze(axis=0)
A    1
Name: 0, dtype: int64

Output of pd.show_versions()

pandas: 0.19.0+416.ge1390cd

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions