Sep-07-2023, 06:28 AM
Probably this won't help you, I don't know pandas. I was just looking at your code, trying to learn a bit about pandas.
If I assign:
If I assign:
description = supplier_table["Description"] type(description) <class 'pandas.core.series.Series'>Try split() on description:
description.split() Traceback (most recent call last): File "/usr/lib/python3.10/idlelib/run.py", line 578, in runcode exec(code, self.locals) File "<pyshell#35>", line 1, in <module> File "/home/pedro/.local/lib/python3.10/site-packages/pandas/core/generic.py", line 5902, in __getattr__ return object.__getattribute__(self, name) AttributeError: 'Series' object has no attribute 'split'. Did you mean: 'plot'?This works however, using your function find_supplier(description) :
supplier_table["Description"].map(find_supplier) 0 B 3 D 4 A 6 B 7 C 9 D 11 E 14 D 16 D 18 D 19 E Name: Description, dtype: objectThis, oddly, does not work, with the same AttributeError: 'Series' object has no attribute 'split'. Did you mean: 'plot'?:
intersection = set(description.split()) & suppliers Traceback (most recent call last): File "/usr/lib/python3.10/idlelib/run.py", line 578, in runcode exec(code, self.locals) File "<pyshell#39>", line 1, in <module> File "/home/pedro/.local/lib/python3.10/site-packages/pandas/core/generic.py", line 5902, in __getattr__ return object.__getattribute__(self, name) AttributeError: 'Series' object has no attribute 'split'. Did you mean: 'plot'?So, because your code works, you CAN split() description, AND you shouldn't be able to split() description!