1

I am new to python

I am trying to extract the city from text which is all over the place:

For an Example: London, HighgateLondon, etc.

I am using GeoText to try and extract this. However, when I run it fills the column with <geotext.geotext.GeoText object at 0x106BFD78> instead of the city.

Despite setting the type it initially did not recoganise that the City Column was a string. Would that be the issue?

    calls = pd.read_csv("Call Analysis.csv", dtype={"Agent": str, "Telephone": 
    float,"Final Queue": str, "Date": str, "Time": str, "Hour": 
    int,"Duration": str,
    "Queue Time": str, "Ring Time [s]": str, "Outcome": str, "Type": str, 
    "Result": str, "Step: Substep": str, "Requisition: Requisition Title": 
    str, 
    "Candidate: DOB_Format": str, "Age": int, "Location": str, "City": str}, 
    parse_dates=["Date", "Time", "Duration", "Queue Time","Ring Time [s]", 
    "Candidate: DOB_Format"], dayfirst=True)

    #set City as a str
    calls["City"] = calls.City.astype(str)

    #extract city from City
    for x, value in calls.iterrows():
       place = GeoText(value["City"])

    #Assign to new column called place
    calls["Place"] = place

    print(calls.head(10))
mousetail
  • 7,009
  • 4
  • 25
  • 45
Red_bull
  • 19
  • 5

0 Answers0