Python Forum
Fuzzy Wuzzy how to get my fuzzyratio displayed
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fuzzy Wuzzy how to get my fuzzyratio displayed
#4
Please post the entire error message, including the traceback. My guess is that one of the columns contains floats.

This works:
from fuzzywuzzy import fuzz
import pandas as pd

df = pd.DataFrame({
    "A": "This is a test".split(), "B": "That was a test".split()
})
df["Ratio"] = df.apply(lambda x: fuzz.ratio(x.A, x.B), axis=1)
print(df)
Output:
A B Ratio 0 This That 50 1 is was 40 2 a a 100 3 test test 100
This fails and gives me the error you are seeing.
from fuzzywuzzy import fuzz
import pandas as pd

df = pd.DataFrame({
    "A": "This is a test".split(), "B": [1.0, 2, 3, 4]
})
df["Ratio"] = df.apply(lambda x: fuzz.ratio(x.A, x.B), axis=1)
print(df)
Error:
TypeError: object of type 'float' has no len()
Reply


Messages In This Thread
RE: Fuzzy Wuzzy how to get my fuzzyratio displayed - by deanhystad - Apr-04-2024, 05:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Table displayed out of order nigelwright7557 3 1,912 Nov-24-2021, 10:07 AM
Last Post: nigelwright7557
  Unexpected output: symbols for derivative not being displayed saucerdesigner 0 2,148 Jun-22-2020, 10:06 PM
Last Post: saucerdesigner
  Auto-copy all displayed "print" results into clipboard? smallabc 1 1,757 Dec-16-2019, 02:10 PM
Last Post: buran
  Percentages displayed as "0.00" Winfried 2 1,903 Nov-15-2019, 05:20 PM
Last Post: Winfried
  implementation fuzzy logic using sckit fuzzy nana_4895 0 2,178 Oct-21-2019, 03:28 AM
Last Post: nana_4895
  Fuzzy match on text columns within dataframe Nsaibot 0 4,399 Aug-27-2018, 10:52 PM
Last Post: Nsaibot
  Exotic stats problem ; mode, fuzzy clusters, etc amyvaulhausen 5 4,080 Aug-06-2018, 04:10 PM
Last Post: Vysero
  Installing fuzzy wuzzy terrancepython11 6 18,585 Mar-25-2017, 06:55 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020