Skip to content

Instantly share code, notes, and snippets.

@ozgurshn
Created January 6, 2019 16:28
Show Gist options
  • Save ozgurshn/2fb78e59e1fa294ab1904a627bae1539 to your computer and use it in GitHub Desktop.
Save ozgurshn/2fb78e59e1fa294ab1904a627bae1539 to your computer and use it in GitHub Desktop.
MLDataTable add new column
let newColumn = data.map { row -> String in
guard
let average = row["deg3"]?.doubleValue
else {
fatalError("Missing or invalid columns in row.")
}
var sentiment = "negative"
if average < 0
{sentiment = "negative"}
else if average == 0
{sentiment = "neutral"}
else
{sentiment = "positive"}
return sentiment
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment