【发布时间】:2017-04-17 21:18:45
【问题描述】:
这是我的代码:
def boba_recs(lat, lng):
f1 = pd.read_csv("./boba_final.csv")
user_loc = Point(lng, lat) # converts user lat/long to point object
# makes dataframe of distances between each boba place and the user loc
f1['Distance'] = [user_loc.distance(Point(xy)) for xy in zip(f1.Longitude, f1.Lat)]
# grabs the three smallest distances
boba = f1.nsmallest(3, 'Distance').set_index('Name') # sets index to name
return(": " + boba['Address'])
这会返回:
Name
Coco Bubble Tea : 129 E 45th St New York, NY 10017
Gong Cha : 75 W 38th St, New York, NY 10018
Smoocha Tea & Juice Bar : 315 5th Ave New York, NY 10016
Name: Address, dtype: object
几乎完美,除了我想摆脱“名称:地址,dtype:对象”行。我已经尝试了一些东西,但它不会在不弄乱其他所有东西的格式的情况下消失。
【问题讨论】: