I am currently making an application in Xcode, and I have a dataframe with a column of CLLocations. I want to make a function that takes a CLLocation as an input, and find the ten closest location rows. In my code below, convert is a dataframe with a column of CLLocations under the column name location. I want to transform the column location into a column of distances from the CLLocation input, and then sort the dataframe values by least to largest distance. But when I run my code, I get a Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). I think that I am doing my .transformColumn wrong. Please have a look at it. Thank you!
func closestCities(to location: CLLocation, in convert: DataFrame, limit: Int) -> DataFrame.Slice{
var closestCities = convert
print(location)
closestCities.transformColumn("location") {
(cityLocation: CLLocation) in cityLocation.distance(from: location)
}
closestCities.renameColumn("location", to: "distance")
return closestCities.sorted(on: "distance", order: .ascending)[..<limit]
}