Before i thought of the recommended pandas way of s.isin, i used the x in s. (do not do this, it’s much slower than s.isin)
I did not realize then that it was searching in the keys of the series and not the values.
Only later i realized if i wanted to map, lambda, in, i have to do s.values to extract series values first.
Why is map, lambda, in (i don’t know which one or combination of them is causing this behaviour), searching within series keys?
I thought the right-hand-side of any in operator just has to be an iterable, and by doing for i in series: print(i) to check what is the iterable contained in any object(series in this case), we indeed see the values (1,2,3) printed, so the items among which membership check is happening should be the values (1,2,3) and not the index (0,1,2)?
How does series.isin work differently from map, lambda, in for it to check membership within series values correctly?
s = pd.Series([1,2,3])
to_search = [1,2,3]
list(map(lambda x:x in s, to_search)) # WHY IS IT SEARCHING KEYS!
list(map(lambda x:x in s.values, to_search))
Thanks, is there a way to see the class and method inheritance chain?
I was thinking which __iter__ is it. There is a __iter__ in pandas\pandas\core\generic.py which is basically the index.
Iterate over info axis.
Info axis as iterator.
Later, i did s.__iter__ to see <bound method IndexOpsMixin.__iter__ then i realize it’s another __iter__ in the mixin.
Is there a easier way to see the inheritance than printing obj.__dunder__ ?
Also, whenever i’m in a method, i must scroll up endlessly to find which class contains this method and risk jumping into another class, any way to jump out of/collapse current cursor position over a method to find it’s class? (i’m using VS Code)