I have two data frames: dataand rules.
>>>data >>>rules
vendor rule
0 googel 0 google
1 google 1 dell
2 googly 2 macbook
I am trying to add two new columns to the framework dataafter calculating the Levenshtein similarity between each seller and the rule. Therefore, in my data block, ideally there should be columns that look like this:
>>>data
vendor rule similarity
0 googel google 0.8
So far I am trying to execute a function applythat will return this structure to me, but the dataframe used does not accept an argument axis.
>>> for index,r in rules.iterrows():
... data[['rule','similarity']]=data['vendor'].apply(lambda row:[r[0],ratio(row[0],r[0])],axis=1)
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/home/mnnr/test/env/test-1.0/runtime/lib/python3.4/site-packages/pandas/core/series.py", line 2220, in apply
mapped = lib.map_infer(values, f, convert=convert_dtype)
File "pandas/src/inference.pyx", line 1088, in pandas.lib.map_infer (pandas/lib.c:62658)
File "/home/mnnr/test/env/test-1.0/runtime/lib/python3.4/site-packages/pandas/core/series.py", line 2209, in <lambda>
f = lambda x: func(x, *args, **kwds)
TypeError: <lambda>() got an unexpected keyword argument 'axis'
Can someone please help me figure out what I'm doing wrong? Any changes I make are just making new mistakes. Thank.
source
share