Created
January 6, 2019 16:28
-
-
Save ozgurshn/2fb78e59e1fa294ab1904a627bae1539 to your computer and use it in GitHub Desktop.
MLDataTable add new column
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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