Column
¶
A named, one-dimensional collection of homogeneous values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
String |
The name of the column. | - |
data |
List<T> |
The data of the column. | [] |
Type parameters:
Name | Upper Bound | Description | Default |
---|---|---|---|
T |
Any? |
- | Any? |
Examples:
Stub code in Column.sdsstub
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 |
|
isNumeric
¶
Whether the column is numeric.
Type: Boolean
isTemporal
¶
Whether the column is temporal.
Type: Boolean
name
¶
The name of the column.
Type: String
plot
¶
The plotter for the column.
Type: ColumnPlotter
rowCount
¶
The number of rows in the column.
Type: Int
type
¶
The type of the column.
Type: DataType
all
¶
Return whether all values in the column satisfy the predicate.
The predicate can return one of three values:
- true, if the value satisfies the predicate.
- false, if the value does not satisfy the predicate.
- null, if the truthiness of the predicate is unknown, e.g. due to missing values.
By default, cases where the truthiness of the predicate is unknown are ignored and this method returns:
- true, if the predicate always returns true or null.
- false, if the predicate returns false at least once.
You can instead enable Kleene logic by setting ignoreUnknown = false
. In this case, this method returns:
- true, if the predicate always returns true.
- false, if the predicate returns false at least once.
- null, if the predicate never returns false, but at least once null.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
predicate |
(cell: Cell<T>) -> (satisfiesPredicate: Cell<Boolean?>) |
The predicate to apply to each value. | - |
ignoreUnknown |
Boolean |
Whether to ignore cases where the truthiness of the predicate is unknown. | true |
Results:
Name | Type | Description |
---|---|---|
allSatisfyPredicate |
Boolean? |
Whether all values in the column satisfy the predicate. |
Examples:
pipeline example {
val column = Column("test", [1, 2, 3]);
val result = column.all((cell) -> cell > 0); // true
}
pipeline example {
val column = Column("test", [1, 2, 3]);
val result = column.all((cell) -> cell < 3); // false
}
Stub code in Column.sdsstub
any
¶
Return whether any value in the column satisfies the predicate.
The predicate can return one of three values:
- true, if the value satisfies the predicate.
- false, if the value does not satisfy the predicate.
- null, if the truthiness of the predicate is unknown, e.g. due to missing values.
By default, cases where the truthiness of the predicate is unknown are ignored and this method returns:
- true, if the predicate returns true at least once.
- false, if the predicate always returns false or null.
You can instead enable Kleene logic by setting ignoreUnknown = false
. In this case, this method returns:
- true, if the predicate returns true at least once.
- false, if the predicate always returns false.
- null, if the predicate never returns true, but at least once null.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
predicate |
(cell: Cell<T>) -> (satisfiesPredicate: Cell<Boolean?>) |
The predicate to apply to each value. | - |
ignoreUnknown |
Boolean |
Whether to ignore cases where the truthiness of the predicate is unknown. | true |
Results:
Name | Type | Description |
---|---|---|
anySatisfyPredicate |
Boolean? |
Whether any value in the column satisfies the predicate. |
Examples:
pipeline example {
val column = Column("test", [1, 2, 3]);
val result = column.any((cell) -> cell > 2); // true
}
pipeline example {
val column = Column("test", [1, 2, 3]);
val result = column.any((cell) -> cell < 0); // false
}
Stub code in Column.sdsstub
correlationWith
¶
Calculate the Pearson correlation between this column and another column.
The Pearson correlation is a value between -1 and 1 that indicates how much the two columns are linearly related:
- A correlation of -1 indicates a perfect negative linear relationship.
- A correlation of 0 indicates no linear relationship.
- A correlation of 1 indicates a perfect positive linear relationship.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
Column<Any> |
The other column to calculate the correlation with. | - |
Results:
Name | Type | Description |
---|---|---|
correlation |
Float |
The Pearson correlation between the two columns. |
Examples:
pipeline example {
val column1 = Column("test", [1, 2, 3]);
val column2 = Column("test", [2, 4, 6]);
val result = column1.correlationWith(column2);
}
pipeline example {
val column1 = Column("test", [1, 2, 3]);
val column2 = Column("test", [3, 2, 1]);
val result = column1.correlationWith(column2);
}
Stub code in Column.sdsstub
countIf
¶
Return how many values in the column satisfy the predicate.
The predicate can return one of three results:
- true, if the value satisfies the predicate.
- false, if the value does not satisfy the predicate.
- null, if the truthiness of the predicate is unknown, e.g. due to missing values.
By default, cases where the truthiness of the predicate is unknown are ignored and this method returns how often the predicate returns true.
You can instead enable Kleene logic by setting ignore_unknown = False
. In this case, this method returns null
if the predicate returns null at least once. Otherwise, it still returns how often the predicate returns true.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
predicate |
(cell: Cell<T>) -> (satisfiesPredicate: Cell<Boolean?>) |
The predicate to apply to each value. | - |
ignoreUnknown |
Boolean |
Whether to ignore cases where the truthiness of the predicate is unknown. | true |
Results:
Name | Type | Description |
---|---|---|
count |
Int? |
The number of values in the column that satisfy the predicate. |
Examples:
pipeline example {
val column = Column("test", [1, 2, 3]);
val result = column.countIf((cell) -> cell > 1); // 2
}
pipeline example {
val column = Column("test", [1, 2, 3]);
val result = column.countIf((cell) -> cell < 0); // 0
}
Stub code in Column.sdsstub
distinctValueCount
¶
Return the number of distinct values in the column.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ignoreMissingValues |
Boolean |
Whether to ignore missing values when counting distinct values. | true |
Results:
Name | Type | Description |
---|---|---|
distinctValueCount |
Int |
The number of distinct values in the column. |
Examples:
pipeline example {
val column = Column("test", [1, 2, 3, 2]);
val result = column.distinctValueCount(); // 3
}
Stub code in Column.sdsstub
getDistinctValues
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ignoreMissingValues |
Boolean |
- | true |
Results:
Name | Type | Description |
---|---|---|
distinctValues |
List<T?> |
- |
Stub code in Column.sdsstub
getValue
¶
Return the column value at specified index. This is equivalent to the []
operator (indexed access).
Nonnegative indices are counted from the beginning (starting at 0), negative indices from the end (starting at -1).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index |
Int |
Index of requested value. | - |
Results:
Name | Type | Description |
---|---|---|
value |
T |
Value at index. |
Examples:
Stub code in Column.sdsstub
idness
¶
Calculate the idness of this column.
We define the idness as the number of distinct values (including missing values) divided by the number of rows. If the column is empty, the idness is 1.0.
A high idness indicates that the column most values in the column are unique. In this case, you must be careful when using the column for analysis, as a model may learn a mapping from this column to the target.
Results:
Name | Type | Description |
---|---|---|
idness |
Float |
The idness of the column. |
Examples:
pipeline example {
val column = Column("test", [1, 2, 3, 2]);
val result = column.idness(); // 0.75
}
max
¶
Return the maximum value in the column.
Results:
Name | Type | Description |
---|---|---|
max |
T? |
The maximum value in the column. |
Examples:
mean
¶
Return the mean of the values in the column.
The mean is the sum of the values divided by the number of values.
Results:
Name | Type | Description |
---|---|---|
mean |
T |
The mean of the values in the column. |
Examples:
median
¶
Return the median of the values in the column.
The median is the value in the middle of the sorted list of values. If the number of values is even, the median is the mean of the two middle values.
Results:
Name | Type | Description |
---|---|---|
median |
T |
The median of the values in the column. |
Examples:
min
¶
Return the minimum value in the column.
Results:
Name | Type | Description |
---|---|---|
min |
T? |
The minimum value in the column. |
Examples:
missingValueCount
¶
Return the number of missing values in the column.
Results:
Name | Type | Description |
---|---|---|
missingValueCount |
Int |
The number of missing values in the column. |
Examples:
pipeline example {
val column = Column("test", [1, null, 3]);
val result = column.missingValueCount(); // 1
}
Stub code in Column.sdsstub
missingValueRatio
¶
Return the missing value ratio.
We define the missing value ratio as the number of missing values in the column divided by the number of rows. If the column is empty, the missing value ratio is 1.0.
A high missing value ratio indicates that the column is dominated by missing values. In this case, the column may not be useful for analysis.
Results:
Name | Type | Description |
---|---|---|
missingValueRatio |
Float |
The ratio of missing values in the column. |
Examples:
pipeline example {
val column = Column("test", [1, null, 3, null]);
val result = column.missingValueRatio(); // 0.5
}
Stub code in Column.sdsstub
mode
¶
Return the mode of the values in the column.
The mode is the value that appears most frequently in the column. If multiple values occur equally often, all of them are returned. The values are sorted in ascending order.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ignoreMissingValues |
Boolean |
Whether to ignore missing values. | true |
Results:
Name | Type | Description |
---|---|---|
mode |
List<T?> |
The mode of the values in the column. |
Examples:
pipeline example {
val column = Column("test", [3, 1, 2, 1, 3]);
val result = column.mode(); // [1, 3]
}
Stub code in Column.sdsstub
none
¶
Return whether no value in the column satisfies the predicate.
The predicate can return one of three values:
- true, if the value satisfies the predicate.
- false, if the value does not satisfy the predicate.
- null, if the truthiness of the predicate is unknown, e.g. due to missing values.
By default, cases where the truthiness of the predicate is unknown are ignored and this method returns:
- true, if the predicate always returns false or null.
- false, if the predicate returns true at least once.
You can instead enable Kleene logic by setting ignoreUnknown = false
. In this case, this method returns:
- true, if the predicate always returns false.
- false, if the predicate returns true at least once.
- null, if the predicate never returns true, but at least once null.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
predicate |
(cell: Cell<T>) -> (satisfiesPredicate: Cell<Boolean?>) |
The predicate to apply to each value. | - |
ignoreUnknown |
Boolean |
Whether to ignore cases where the truthiness of the predicate is unknown. | true |
Results:
Name | Type | Description |
---|---|---|
noneSatisfyPredicate |
Int? |
Whether no value in the column satisfies the predicate. |
Examples:
pipeline example {
val column = Column("test", [1, 2, 3]);
val result = column.none((cell) -> cell < 0); // true
}
pipeline example {
val column = Column("test", [1, 2, 3]);
val result = column.none((cell) -> cell > 2); // false
}
Stub code in Column.sdsstub
rename
¶
Return a new column with a new name.
Note: The original column is not modified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
newName |
String |
The new name of the column. | - |
Results:
Name | Type | Description |
---|---|---|
renamedColumn |
Column<T> |
A new column with the new name. |
Examples:
pipeline example {
val column = Column("test", [1, 2, 3]);
val result = column.rename("new_name");
// Column("new_name", [1, 2, 3])
}
Stub code in Column.sdsstub
stability
¶
Return the stability of the column.
We define the stability as the number of occurrences of the most common non-missing value divided by the total number of non-missing values. If the column is empty or all values are missing, the stability is 1.0.
A high stability indicates that the column is dominated by a single value. In this case, the column may not be useful for analysis.
Results:
Name | Type | Description |
---|---|---|
stability |
Float |
The stability of the column. |
Examples:
pipeline example {
val column = Column("test", [1, 1, 2, 3, null]);
val result = column.stability(); // 0.5
}
standardDeviation
¶
Return the standard deviation of the values in the column.
The standard deviation is the square root of the variance.
Results:
Name | Type | Description |
---|---|---|
standardDeviation |
Float |
The standard deviation of the values in the column. If no standard deviation can be calculated due to the type of the column, null is returned. |
Examples:
pipeline example {
val column = Column("test", [1, 2, 3]);
val result = column.standardDeviation(); // 1.0
}
Stub code in Column.sdsstub
summarizeStatistics
¶
Return a table with important statistics about the column.
Results:
Name | Type | Description |
---|---|---|
statistics |
Table |
The table with statistics. |
Examples:
Stub code in Column.sdsstub
toList
¶
Return the values of the column in a list.
Results:
Name | Type | Description |
---|---|---|
values |
List<T> |
The values of the column in a list. |
Examples:
pipeline example {
val column = Column("test", [1, 2, 3]);
val result = column.toList(); // [1, 2, 3]
}
toTable
¶
Create a table that contains only this column.
Results:
Name | Type | Description |
---|---|---|
table |
Table |
The table with this column. |
Examples:
pipeline example {
val column = Column("test", [1, 2, 3]);
val result = column.toTable();
// Table({"test": [1, 2, 3]})
}
transform
¶
Return a new column with values transformed by the transformer.
Note: The original column is not modified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transformer |
(cell: Cell<T>) -> (transformedCell: Cell<R>) |
The transformer to apply to each value. | - |
Results:
Name | Type | Description |
---|---|---|
transformedColumn |
Column<R> |
A new column with transformed values. |
Type parameters:
Name | Upper Bound | Description | Default |
---|---|---|---|
R |
Any? |
- | - |
Examples:
pipeline example {
val column = Column("test", [1, 2, 3]);
val result = column.transform((cell) -> cell * 2);
// Column("test", [2, 4, 6])
}
Stub code in Column.sdsstub
variance
¶
Return the variance of the values in the column.
The variance is the average of the squared differences from the mean.
Results:
Name | Type | Description |
---|---|---|
variance |
Float |
The variance of the values in the column. If no variance can be calculated due to the type of the column, null is returned. |
Examples: