def get_loctype(location, date_index):
"""Returns a pandas Series of the location type for each day.
Locations with a changetime have type *city* before that day, and *conflict*
after it.
"""
n_days = len(date_index)
changetime = location.time
if pd.isnull(changetime):
loctype = location.location_type
else:
#0:changetime, loctype = "city"
loctype = ['city'] * int(changetime)
#changetime:-1, loctype = "conflict"
loctype +=['conflict'] * int(n_days - changetime)
return pd.Series(loctype, index=date_index)
评论列表
文章目录