datatable icon indicating copy to clipboard operation
datatable copied to clipboard

Removing a column that is not in the columnset is error

Open ztsweet opened this issue 4 years ago • 10 comments

import datatable as dt
from datatable import f
#
#print(dt.__version__)
# '1.0.0'
df1 = dt.Frame({'a':[1, 2, 3], 'b':[2, 3, 4],'c':[1., 2., 3.]})
df1[:, f[:].remove(f['d'])]
#
# KeyError: Column d does not exist in the Frame; did you mean a, b or c?

ztsweet avatar Jul 12 '21 02:07 ztsweet

@ztsweet , the error message seems right. What is your expectation?

samukweku avatar Jul 12 '21 03:07 samukweku

@ztsweet neat… @st-pasha @oleksiyskononenko can weigh in on this … seems like a bug

samukweku avatar Jul 12 '21 05:07 samukweku

@ztsweet kindly add the datatable version. Edit it using the guidelines, so the maintainers can properly look into it

samukweku avatar Jul 12 '21 05:07 samukweku

@samukweku the datatable's version is '1.0.0'

ztsweet avatar Jul 12 '21 05:07 ztsweet

So, either the behavior is wrong here (i.e. there should not be an exception), or the documentation is wrong.

But which one? What are your guys' thoughts on this?

st-pasha avatar Jul 12 '21 20:07 st-pasha

Throwing an error like it's done now seems more appropriate to me. I suggest updating the documentation to match the behaviour.

pradkrish avatar Jul 12 '21 22:07 pradkrish

The documentation seems the right way to go, if we are treating it like a set

samukweku avatar Jul 12 '21 22:07 samukweku

@oleksiyskononenko what are your thoughts on this?

pradkrish avatar Nov 13 '21 17:11 pradkrish

@pradkrish The Python's .remove() method results in an error for both lists and sets, when the element to be removed is absent in the list/set.

l = ["a", "b", "c"]
l.remove("d") #ValueError: list.remove(x): x not in list
s = {"a", "b", "c"}
s.remove("d") #KeyError: 'd'

So my feeling is that we need to adjust documentation.

oleksiyskononenko avatar Nov 16 '21 18:11 oleksiyskononenko