fix for categorical missing values

This commit is contained in:
Ben Fry
2014-04-16 15:40:33 -04:00
parent 20ce7605e3
commit 400fda8bb0
2 changed files with 11 additions and 1 deletions

View File

@@ -2087,7 +2087,12 @@ public class Table {
if (piece == null) {
indexData[row] = missingCategory;
} else {
indexData[row] = columnCategories[col].index(String.valueOf(piece));
String peace = String.valueOf(piece);
if (peace.equals(missingString)) { // missingString might be null
indexData[row] = missingCategory;
} else {
indexData[row] = columnCategories[col].index(peace);
}
}
break;
default:
@@ -2933,6 +2938,9 @@ public class Table {
}
/**
* Treat entries with this string as "missing". Also used for categorial.
*/
public void setMissingString(String value) {
missingString = value;
}
@@ -3562,6 +3570,7 @@ public class Table {
read(input);
}
/** gets the index, and creates one if it doesn't already exist. */
int index(String key) {
Integer value = dataToIndex.get(key);
if (value != null) {

View File

@@ -1,4 +1,5 @@
0226 core
X fix parsing with missing categorical values
_ XML.getChildren() throwing NPE when getInt() called on non-existent var