Skip to content

BUG: in error message raised when invalid axis parameter #25555

@simonjayhawkins

Description

@simonjayhawkins

Code Sample, a copy-pastable example if possible

import numpy as np from pandas import DataFrame df = DataFrame(np.random.randn(6, 4)) df.dropna(axis=3)

Problem description

0.25.0.dev0+198.gd10bbce34

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\core\frame.py", line 4575, in dropna axis = self._get_axis_number(axis) File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\core\generic.py", line 361, in _get_axis_number .format(axis, type(cls))) ValueError: No axis named 3 for object type <class 'type'>

0.23.4:

--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-2-5ab8608d1d61> in <module> 2 from pandas import DataFrame 3 df = DataFrame(np.random.randn(6, 4)) ----> 4 df.dropna(axis=3) ~\Anaconda3\lib\site-packages\pandas\core\frame.py in dropna(self, axis, how, thresh, subset, inplace) 4274 axis=ax) 4275 else: -> 4276 axis = self._get_axis_number(axis) 4277 agg_axis = 1 - axis 4278 ~\Anaconda3\lib\site-packages\pandas\core\generic.py in _get_axis_number(self, axis) 373 pass 374 raise ValueError('No axis named {0} for object type {1}' --> 375 .format(axis, type(self))) 376 377 def _get_axis_name(self, axis): ValueError: No axis named 3 for object type <class 'pandas.core.frame.DataFrame'>

Expected Output

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error ReportingIncorrect or improved errors from pandas

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions