File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
core/src/main/java/tech/tablesaw Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -300,7 +300,7 @@ public String getUnformattedString(final int row) {
300
300
}
301
301
302
302
@ Override
303
- public NumberColumn emptyCopy () {
303
+ public DoubleColumn emptyCopy () {
304
304
return emptyCopy (DEFAULT_ARRAY_SIZE );
305
305
}
306
306
Original file line number Diff line number Diff line change @@ -62,6 +62,39 @@ public ColumnType type() {
62
62
return type ;
63
63
}
64
64
65
+ @ Override
66
+ public abstract C emptyCopy ();
67
+
68
+ /**
69
+ * Create a copy of this column where missing values are replaced with the given default value
70
+ */
71
+ public C fillMissing (T defaultVal ) {
72
+ C newCol = emptyCopy ();
73
+ for (int i = 0 ; i < this .size (); i ++) {
74
+ if (isMissing (i )) {
75
+ newCol .set (i , defaultVal );
76
+ } else {
77
+ newCol .set (1 , getObject (i ));
78
+ }
79
+ }
80
+ return newCol ;
81
+ }
82
+
83
+ /**
84
+ * Create a copy of this column where missing values are replaced with the corresponding value in the given column
85
+ */
86
+ public C fillMissing (C other ) {
87
+ C newCol = emptyCopy ();
88
+ for (int i = 0 ; i < this .size (); i ++) {
89
+ if (isMissing (i )) {
90
+ newCol .set (i , other .getObject (i ));
91
+ } else {
92
+ newCol .set (1 , getObject (i ));
93
+ }
94
+ }
95
+ return newCol ;
96
+ }
97
+
65
98
public abstract C set (int i , T val );
66
99
67
100
public abstract T getObject (int i );
You can’t perform that action at this time.
0 commit comments