[Pandas-dev] Dataframe - drop function - passing in invalid row name
Vinodhini Balusamy
me.vinob at gmail.com
Mon Jan 8 06:59:04 EST 2018
Hi,
I am new to pandas. Beginner level in learning Data science skills.
I came across the below case while learning about DatFrame structure drop function.
>>> items
item name
store1 dress V
store2 food A
store2 water C
CASE 1 : axis set to column and given a value which is not available in the structure. Gives ValueError.
>>> items.drop('abcd',axis=1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/pandas/core/generic.py", line 2530, in drop
obj = obj._drop_axis(labels, axis, level=level, errors=errors)
File "/usr/local/lib/python3.6/site-packages/pandas/core/generic.py", line 2562, in _drop_axis
new_axis = axis.drop(labels, errors=errors)
File "/usr/local/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 3744, in drop
labels[mask])
ValueError: labels ['abcd'] not contained in axis
CASE 2 : axis set to row, and given a value which is not available in structure should behave in the same way as the above case does.
Instead it just prints the structure table. Shouldn’t it be throwing ValueError ?
>>> items.drop('abcd',axis=0)
item name
store1 dress V
store2 food A
store2 water C
>>>
Kindly correct me if i am wrong here. Or it is been this way for any specific reason in design ?
Thanks in advance.
Kind Rgds,
Vinodhini B
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pandas-dev/attachments/20180108/04773ded/attachment.html>
More information about the Pandas-dev
mailing list