Skip to content

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 ColumnType? The type of the column. If null (default), the type is inferred from the data. null

Type parameters:

Name Upper Bound Description Default
T Any? - Any?

Examples:

pipeline example {
    out Column("a", [1, 2, 3]);
    out Column("a", [1, 2, 3], type = ColumnType.string());
}
Stub code in Column.sdsstub

 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
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
@Category(DataScienceCategory.BasicElement)
class Column<out T = Any?>(
    name: String,
    data: List<T>,
    type: ColumnType? = null
) {
    /**
     * The name of the column.
     */
    attr name: String
    /**
     * The number of rows.
     *
     * **Note:** This operation must fully load the data into memory, which can be expensive.
     */
    @PythonName("row_count") attr rowCount: Int
    /**
     * The plotter for the column.
     *
     * Call methods of the plotter to create various plots for the column.
     */
    attr plot: ColumnPlotter
    /**
     * The type of the column.
     */
    attr type: ColumnType

    /**
     * Return the distinct values in the column.
     *
     * @param ignoreMissingValues Whether to ignore missing values.
     *
     * @result distinctValues The distinct values in the column.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3, 2]);
     *     out column.getDistinctValues();
     * }
     */
    @Pure
    @PythonName("get_distinct_values")
    fun getDistinctValues(
        @PythonName("ignore_missing_values") ignoreMissingValues: Boolean = true
    ) -> distinctValues: List<T?>

    /**
     * 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).
     *
     * @param index Index of requested value.
     *
     * @result value Value at index.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3]);
     *     out column.getValue(0);
     *     out column[0];
     *     out column.getValue(-1);
     *     out column[-1];
     * }
     */
    @Pure
    @PythonName("get_value")
    fun getValue(
        index: Int
    ) -> value: T

    /**
     * Check 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.
     *
     * @param predicate The predicate to apply to each value.
     * @param ignoreUnknown Whether to ignore cases where the truthiness of the predicate is unknown.
     *
     * @result allSatisfyPredicate Whether all values in the column satisfy the predicate.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3, null]);
     *     out column.all((cell) -> cell > 0);
     *     out column.all((cell) -> cell < 3);
     *     out column.all((cell) -> cell > 0, ignoreUnknown = false);
     *     out column.all((cell) -> cell < 3, ignoreUnknown = false);
     * }
     */
    @Pure
    @Category(DataScienceCategory.DataExplorationQGeneral)
    fun all(
        predicate: (cell: Cell<T>) -> satisfiesPredicate: Cell<Boolean?>,
        @PythonName("ignore_unknown") ignoreUnknown: Boolean = true
    ) -> allSatisfyPredicate: Boolean?

    /**
     * Check 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.
     *
     * @param predicate The predicate to apply to each value.
     * @param ignoreUnknown Whether to ignore cases where the truthiness of the predicate is unknown.
     *
     * @result anySatisfyPredicate Whether any value in the column satisfies the predicate.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3, null]);
     *     out column.any((cell) -> cell > 2);
     *     out column.any((cell) -> cell < 0);
     *     out column.any((cell) -> cell > 2, ignoreUnknown = false);
     *     out column.any((cell) -> cell < 0, ignoreUnknown = false);
     * }
     */
    @Pure
    @Category(DataScienceCategory.DataExplorationQGeneral)
    fun any(
        predicate: (cell: Cell<T>) -> satisfiesPredicate: Cell<Boolean?>,
        @PythonName("ignore_unknown") ignoreUnknown: Boolean = true
    ) -> anySatisfyPredicate: Boolean?

    /**
     * Count 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 `ignoreUnknown = 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.
     *
     * @param predicate The predicate to apply to each value.
     * @param ignoreUnknown Whether to ignore cases where the truthiness of the predicate is unknown.
     *
     * @result count The number of values in the column that satisfy the predicate.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3, null]);
     *     out column.countIf((cell) -> cell > 1);
     *     out column.countIf((cell) -> cell < 0, ignoreUnknown = false);
     * }
     */
    @Pure
    @PythonName("count_if")
    fun countIf(
        predicate: (cell: Cell<T>) -> satisfiesPredicate: Cell<Boolean?>,
        @PythonName("ignore_unknown") ignoreUnknown: Boolean = true
    ) -> count: Int?

    /**
     * Check 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.
     *
     * @param predicate The predicate to apply to each value.
     * @param ignoreUnknown Whether to ignore cases where the truthiness of the predicate is unknown.
     *
     * @result noneSatisfyPredicate Whether no value in the column satisfies the predicate.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3, null]);
     *     out column.none((cell) -> cell < 0);
     *     out column.none((cell) -> cell > 2);
     *     out column.none((cell) -> cell < 0, ignoreUnknown = false);
     *     out column.none((cell) -> cell > 2, ignoreUnknown = false);
     * }
     */
    @Pure
    @Category(DataScienceCategory.DataExplorationQGeneral)
    fun none(
        predicate: (cell: Cell<T>) -> satisfiesPredicate: Cell<Boolean?>,
        @PythonName("ignore_unknown") ignoreUnknown: Boolean = true
    ) -> noneSatisfyPredicate: Boolean?

    /**
     * Rename the column and return the result as a new column.
     *
     * **Note:** The original column is not modified.
     *
     * @param newName The new name of the column.
     *
     * @result newColumn A column with the new name.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3]);
     *     out column.rename("b");
     * }
     */
    @Pure
    @Category(DataScienceCategory.DataProcessingQColumn)
    fun rename(
        @PythonName("new_name") newName: String
    ) -> newColumn: Column<T>

    /**
     * Transform the values in the column and return the result as a new column.
     *
     * **Note:** The original column is not modified.
     *
     * @param transformer The transformer to apply to each value.
     *
     * @result newColumn A column with the transformed values.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3]);
     *     out column.transform((cell) -> 2 * cell);
     * }
     */
    @Pure
    @Category(DataScienceCategory.DataProcessingQColumn)
    fun transform<R>(
        transformer: (cell: Cell<T>) -> transformedCell: Cell<R>
    ) -> newColumn: Column<R>

    /**
     * Return a table with important statistics about the column.
     *
     * !!! warning "API Stability"
     *
     *     Do not rely on the exact output of this method. In future versions, we may change the displayed statistics
     *     without prior notice.
     *
     * @result statistics The table with statistics.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 3]);
     *     out column.summarizeStatistics();
     * }
     */
    @Pure
    @PythonName("summarize_statistics")
    fun summarizeStatistics() -> statistics: Table

    /**
     * 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.
     *
     * A value of 0 does not necessarily mean that the columns are independent. It only means that there is no linear
     * relationship between the columns.
     *
     * @param other The other column to calculate the correlation with.
     *
     * @result correlation The Pearson correlation between the two columns.
     *
     * @example
     * pipeline example {
     *     val column1 = Column("a", [1, 2, 3]);
     *     val column2 = Column("a", [2, 4, 6]);
     *     out column1.correlationWith(column2);
     * }
     *
     * @example
     * pipeline example {
     *     val column1 = Column("a", [1, 2, 3]);
     *     val column2 = Column("a", [3, 2, 1]);
     *     out column1.correlationWith(column2);
     * }
     */
    @Pure
    @PythonName("correlation_with")
    @Category(DataScienceCategory.DataExplorationQMetric)
    fun correlationWith(
        other: Column<Any>
    ) -> correlation: Float

    /**
     * Return the number of distinct values in the column.
     *
     * @param ignoreMissingValues Whether to ignore missing values when counting distinct values.
     *
     * @result distinctValueCount The number of distinct values in the column.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3, 2, null]);
     *     out column.distinctValueCount();
     *     out column.distinctValueCount(ignoreMissingValues = false);
     * }
     */
    @Pure
    @PythonName("distinct_value_count")
    @Category(DataScienceCategory.DataExplorationQMetric)
    fun distinctValueCount(
        @PythonName("ignore_missing_values") ignoreMissingValues: Boolean = true
    ) -> distinctValueCount: Int

    /**
     * Return 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 most values in the column are unique. In this case, you must be careful when using
     * the column for analysis, as a model might learn a mapping from this column to the target, which might not
     * generalize well. You can generally ignore this metric for floating point columns.
     *
     * @result idness The idness of the column.
     *
     * @example
     * pipeline example {
     *     val column1 = Column("a", [1, 2, 3]);
     *     out column1.idness();
     * }
     *
     * @example
     * pipeline example {
     *     val column2 = Column("a", [1, 2, 3, 2]);
     *     out column2.idness();
     * }
     */
    @Pure
    @Category(DataScienceCategory.DataExplorationQMetric)
    fun idness() -> idness: Float

    /**
     * Return the maximum value in the column.
     *
     * @result max The maximum value in the column.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3]);
     *     out column.max();
     * }
     */
    @Pure
    @Category(DataScienceCategory.DataExplorationQMetric)
    fun max() -> max: T?

    /**
     * Return the mean of the values in the column.
     *
     * The mean is the sum of the values divided by the number of values.
     *
     * @result mean The mean of the values in the column.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3]);
     *     out column.mean();
     * }
     */
    @Pure
    @Category(DataScienceCategory.DataExplorationQMetric)
    fun mean() -> mean: T

    /**
     * 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.
     *
     * @result median The median of the values in the column.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3]);
     *     out column.median();
     * }
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3, 4]);
     *     out column.median();
     * }
     */
    @Pure
    @Category(DataScienceCategory.DataExplorationQMetric)
    fun median() -> median: T

    /**
     * Return the minimum value in the column.
     *
     * @result min The minimum value in the column.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3]);
     *     out column.min();
     * }
     */
    @Pure
    @Category(DataScienceCategory.DataExplorationQMetric)
    fun min() -> min: T?

    /**
     * Return the number of missing values in the column.
     *
     * @result missingValueCount The number of missing values in the column.
     *
     * @example
     * pipeline example {
     *     val column1 = Column("a", [1, 2, 3]);
     *     out column1.missingValueCount();
     * }
     *
     * @example
     * pipeline example {
     *     val column2 = Column("a", [1, null, 3]);
     *     out column2.missingValueCount();
     * }
     */
    @Pure
    @PythonName("missing_value_count")
    @Category(DataScienceCategory.DataExplorationQMetric)
    fun missingValueCount() -> missingValueCount: Int

    /**
     * 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.
     *
     * @result missingValueRatio The ratio of missing values in the column.
     *
     * @example
     * pipeline example {
     *     val column1 = Column("a", [1, 2, 3]);
     *     out column1.missingValueRatio();
     * }
     *
     * @example
     * pipeline example {
     *     val column2 = Column("a", [1, null]);
     *     out column2.missingValueRatio();
     * }
     *
     * @example
     * pipeline example {
     *     val column3 = Column("a", []);
     *     out column3.missingValueRatio();
     * }
     */
    @Pure
    @PythonName("missing_value_ratio")
    @Category(DataScienceCategory.DataExplorationQMetric)
    fun missingValueRatio() -> missingValueRatio: Float

    /**
     * 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.
     *
     * @param ignoreMissingValues Whether to ignore missing values.
     *
     * @result mode The mode of the values in the column.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [3, 1, 2, 1, 3]);
     *     out column.mode();
     * }
     */
    @Pure
    @Category(DataScienceCategory.DataExplorationQMetric)
    fun mode(
        @PythonName("ignore_missing_values") ignoreMissingValues: Boolean = true
    ) -> mode: List<T?>

    /**
     * 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.
     *
     * @result stability The stability of the column.
     *
     * @example
     * pipeline example {
     *     val column1 = Column("a", [1, 1, 2, 3, null]);
     *     out column1.stability();
     * }
     *
     * @example
     * pipeline example {
     *     val column2 = Column("a", [1, 1, 1, 1]);
     *     out column2.stability();
     * }
     *
     * @example
     * pipeline example {
     *     val column3 = Column("a", []);
     *     out column3.stability();
     * }
     */
    @Pure
    @Category(DataScienceCategory.DataExplorationQMetric)
    fun stability() -> stability: Float

    /**
     * Return the standard deviation of the values in the column.
     *
     * The standard deviation is the square root of the variance.
     *
     * @result standardDeviation The standard deviation of the values in the column.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3]);
     *     out column.standardDeviation();
     * }
     */
    @Pure
    @PythonName("standard_deviation")
    @Category(DataScienceCategory.DataExplorationQMetric)
    fun standardDeviation() -> standardDeviation: Float

    /**
     * Return the variance of the values in the column.
     *
     * The variance is the sum of the squared differences from the mean divided by the number of values minus one.
     *
     * @result variance The variance of the values in the column.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3]);
     *     out column.variance();
     * }
     */
    @Pure
    @Category(DataScienceCategory.DataExplorationQMetric)
    fun variance() -> variance: Float

    /**
     * Return the values of the column in a list.
     *
     * @result values The values of the column.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3]);
     *     out column.toList();
     * }
     */
    @Pure
    @PythonName("to_list")
    @Category(DataScienceCategory.UtilitiesQConversion)
    fun toList() -> values: List<T>

    /**
     * Create a table that contains only this column.
     *
     * @result table The table with this column.
     *
     * @example
     * pipeline example {
     *     val column = Column("a", [1, 2, 3]);
     *     out column.toTable();
     * }
     */
    @Pure
    @PythonName("to_table")
    @Category(DataScienceCategory.UtilitiesQConversion)
    fun toTable() -> table: Table
}

name

The name of the column.

Type: String

plot

The plotter for the column.

Call methods of the plotter to create various plots for the column.

Type: ColumnPlotter

rowCount

The number of rows.

Note: This operation must fully load the data into memory, which can be expensive.

Type: Int

type

The type of the column.

Type: ColumnType

all

Check 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("a", [1, 2, 3, null]);
    out column.all((cell) -> cell > 0);
    out column.all((cell) -> cell < 3);
    out column.all((cell) -> cell > 0, ignoreUnknown = false);
    out column.all((cell) -> cell < 3, ignoreUnknown = false);
}
Stub code in Column.sdsstub

@Pure
@Category(DataScienceCategory.DataExplorationQGeneral)
fun all(
    predicate: (cell: Cell<T>) -> satisfiesPredicate: Cell<Boolean?>,
    @PythonName("ignore_unknown") ignoreUnknown: Boolean = true
) -> allSatisfyPredicate: Boolean?

any

Check 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("a", [1, 2, 3, null]);
    out column.any((cell) -> cell > 2);
    out column.any((cell) -> cell < 0);
    out column.any((cell) -> cell > 2, ignoreUnknown = false);
    out column.any((cell) -> cell < 0, ignoreUnknown = false);
}
Stub code in Column.sdsstub

@Pure
@Category(DataScienceCategory.DataExplorationQGeneral)
fun any(
    predicate: (cell: Cell<T>) -> satisfiesPredicate: Cell<Boolean?>,
    @PythonName("ignore_unknown") ignoreUnknown: Boolean = true
) -> anySatisfyPredicate: Boolean?

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.

A value of 0 does not necessarily mean that the columns are independent. It only means that there is no linear relationship between the columns.

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("a", [1, 2, 3]);
    val column2 = Column("a", [2, 4, 6]);
    out column1.correlationWith(column2);
}
pipeline example {
    val column1 = Column("a", [1, 2, 3]);
    val column2 = Column("a", [3, 2, 1]);
    out column1.correlationWith(column2);
}

Stub code in Column.sdsstub

@Pure
@PythonName("correlation_with")
@Category(DataScienceCategory.DataExplorationQMetric)
fun correlationWith(
    other: Column<Any>
) -> correlation: Float

countIf

Count 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 ignoreUnknown = 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("a", [1, 2, 3, null]);
    out column.countIf((cell) -> cell > 1);
    out column.countIf((cell) -> cell < 0, ignoreUnknown = false);
}
Stub code in Column.sdsstub

@Pure
@PythonName("count_if")
fun countIf(
    predicate: (cell: Cell<T>) -> satisfiesPredicate: Cell<Boolean?>,
    @PythonName("ignore_unknown") ignoreUnknown: Boolean = true
) -> count: Int?

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("a", [1, 2, 3, 2, null]);
    out column.distinctValueCount();
    out column.distinctValueCount(ignoreMissingValues = false);
}
Stub code in Column.sdsstub

@Pure
@PythonName("distinct_value_count")
@Category(DataScienceCategory.DataExplorationQMetric)
fun distinctValueCount(
    @PythonName("ignore_missing_values") ignoreMissingValues: Boolean = true
) -> distinctValueCount: Int

getDistinctValues

Return the distinct values in the column.

Parameters:

Name Type Description Default
ignoreMissingValues Boolean Whether to ignore missing values. true

Results:

Name Type Description
distinctValues List<T?> The distinct values in the column.

Examples:

pipeline example {
    val column = Column("a", [1, 2, 3, 2]);
    out column.getDistinctValues();
}
Stub code in Column.sdsstub

@Pure
@PythonName("get_distinct_values")
fun getDistinctValues(
    @PythonName("ignore_missing_values") ignoreMissingValues: Boolean = true
) -> distinctValues: List<T?>

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:

pipeline example {
    val column = Column("a", [1, 2, 3]);
    out column.getValue(0);
    out column[0];
    out column.getValue(-1);
    out column[-1];
}
Stub code in Column.sdsstub

@Pure
@PythonName("get_value")
fun getValue(
    index: Int
) -> value: T

idness

Return 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 most values in the column are unique. In this case, you must be careful when using the column for analysis, as a model might learn a mapping from this column to the target, which might not generalize well. You can generally ignore this metric for floating point columns.

Results:

Name Type Description
idness Float The idness of the column.

Examples:

pipeline example {
    val column1 = Column("a", [1, 2, 3]);
    out column1.idness();
}
pipeline example {
    val column2 = Column("a", [1, 2, 3, 2]);
    out column2.idness();
}

Stub code in Column.sdsstub

@Pure
@Category(DataScienceCategory.DataExplorationQMetric)
fun idness() -> idness: Float

max

Return the maximum value in the column.

Results:

Name Type Description
max T? The maximum value in the column.

Examples:

pipeline example {
    val column = Column("a", [1, 2, 3]);
    out column.max();
}
Stub code in Column.sdsstub

@Pure
@Category(DataScienceCategory.DataExplorationQMetric)
fun max() -> max: T?

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:

pipeline example {
    val column = Column("a", [1, 2, 3]);
    out column.mean();
}
Stub code in Column.sdsstub

@Pure
@Category(DataScienceCategory.DataExplorationQMetric)
fun mean() -> mean: T

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:

pipeline example {
    val column = Column("a", [1, 2, 3]);
    out column.median();
}
pipeline example {
    val column = Column("a", [1, 2, 3, 4]);
    out column.median();
}

Stub code in Column.sdsstub

@Pure
@Category(DataScienceCategory.DataExplorationQMetric)
fun median() -> median: T

min

Return the minimum value in the column.

Results:

Name Type Description
min T? The minimum value in the column.

Examples:

pipeline example {
    val column = Column("a", [1, 2, 3]);
    out column.min();
}
Stub code in Column.sdsstub

@Pure
@Category(DataScienceCategory.DataExplorationQMetric)
fun min() -> min: T?

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 column1 = Column("a", [1, 2, 3]);
    out column1.missingValueCount();
}
pipeline example {
    val column2 = Column("a", [1, null, 3]);
    out column2.missingValueCount();
}

Stub code in Column.sdsstub

@Pure
@PythonName("missing_value_count")
@Category(DataScienceCategory.DataExplorationQMetric)
fun missingValueCount() -> missingValueCount: Int

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 column1 = Column("a", [1, 2, 3]);
    out column1.missingValueRatio();
}
pipeline example {
    val column2 = Column("a", [1, null]);
    out column2.missingValueRatio();
}
pipeline example {
    val column3 = Column("a", []);
    out column3.missingValueRatio();
}

Stub code in Column.sdsstub

@Pure
@PythonName("missing_value_ratio")
@Category(DataScienceCategory.DataExplorationQMetric)
fun missingValueRatio() -> missingValueRatio: Float

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("a", [3, 1, 2, 1, 3]);
    out column.mode();
}
Stub code in Column.sdsstub

@Pure
@Category(DataScienceCategory.DataExplorationQMetric)
fun mode(
    @PythonName("ignore_missing_values") ignoreMissingValues: Boolean = true
) -> mode: List<T?>

none

Check 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 Boolean? Whether no value in the column satisfies the predicate.

Examples:

pipeline example {
    val column = Column("a", [1, 2, 3, null]);
    out column.none((cell) -> cell < 0);
    out column.none((cell) -> cell > 2);
    out column.none((cell) -> cell < 0, ignoreUnknown = false);
    out column.none((cell) -> cell > 2, ignoreUnknown = false);
}
Stub code in Column.sdsstub

@Pure
@Category(DataScienceCategory.DataExplorationQGeneral)
fun none(
    predicate: (cell: Cell<T>) -> satisfiesPredicate: Cell<Boolean?>,
    @PythonName("ignore_unknown") ignoreUnknown: Boolean = true
) -> noneSatisfyPredicate: Boolean?

rename

Rename the column and return the result as a new column.

Note: The original column is not modified.

Parameters:

Name Type Description Default
newName String The new name of the column. -

Results:

Name Type Description
newColumn Column<T> A column with the new name.

Examples:

pipeline example {
    val column = Column("a", [1, 2, 3]);
    out column.rename("b");
}
Stub code in Column.sdsstub

@Pure
@Category(DataScienceCategory.DataProcessingQColumn)
fun rename(
    @PythonName("new_name") newName: String
) -> newColumn: Column<T>

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 column1 = Column("a", [1, 1, 2, 3, null]);
    out column1.stability();
}
pipeline example {
    val column2 = Column("a", [1, 1, 1, 1]);
    out column2.stability();
}
pipeline example {
    val column3 = Column("a", []);
    out column3.stability();
}

Stub code in Column.sdsstub

@Pure
@Category(DataScienceCategory.DataExplorationQMetric)
fun stability() -> stability: Float

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.

Examples:

pipeline example {
    val column = Column("a", [1, 2, 3]);
    out column.standardDeviation();
}
Stub code in Column.sdsstub

@Pure
@PythonName("standard_deviation")
@Category(DataScienceCategory.DataExplorationQMetric)
fun standardDeviation() -> standardDeviation: Float

summarizeStatistics

Return a table with important statistics about the column.

API Stability

Do not rely on the exact output of this method. In future versions, we may change the displayed statistics without prior notice.

Results:

Name Type Description
statistics Table The table with statistics.

Examples:

pipeline example {
    val column = Column("a", [1, 3]);
    out column.summarizeStatistics();
}
Stub code in Column.sdsstub

@Pure
@PythonName("summarize_statistics")
fun summarizeStatistics() -> statistics: Table

toList

Return the values of the column in a list.

Results:

Name Type Description
values List<T> The values of the column.

Examples:

pipeline example {
    val column = Column("a", [1, 2, 3]);
    out column.toList();
}
Stub code in Column.sdsstub

@Pure
@PythonName("to_list")
@Category(DataScienceCategory.UtilitiesQConversion)
fun toList() -> values: List<T>

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("a", [1, 2, 3]);
    out column.toTable();
}
Stub code in Column.sdsstub

@Pure
@PythonName("to_table")
@Category(DataScienceCategory.UtilitiesQConversion)
fun toTable() -> table: Table

transform

Transform the values in the column and return the result as a new column.

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
newColumn Column<R> A column with the transformed values.

Type parameters:

Name Upper Bound Description Default
R Any? - -

Examples:

pipeline example {
    val column = Column("a", [1, 2, 3]);
    out column.transform((cell) -> 2 * cell);
}
Stub code in Column.sdsstub

@Pure
@Category(DataScienceCategory.DataProcessingQColumn)
fun transform<R>(
    transformer: (cell: Cell<T>) -> transformedCell: Cell<R>
) -> newColumn: Column<R>

variance

Return the variance of the values in the column.

The variance is the sum of the squared differences from the mean divided by the number of values minus one.

Results:

Name Type Description
variance Float The variance of the values in the column.

Examples:

pipeline example {
    val column = Column("a", [1, 2, 3]);
    out column.variance();
}
Stub code in Column.sdsstub

@Pure
@Category(DataScienceCategory.DataExplorationQMetric)
fun variance() -> variance: Float