1

我是 python 新手

我正在尝试从无处不在的文本中提取城市:

举个例子:London, HighgateLondon, etc.

我正在GeoText尝试提取它。但是,当我运行它时,它会填充列<geotext.geotext.GeoText object at 0x106BFD78>而不是城市。

尽管设置了类型,但它最初并没有识别出 City Column 是一个字符串。那会是问题吗?

    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))
4

0 回答 0