Package tech.tablesaw.api
Class NumberColumn<C extends NumberColumn<C,T>,T extends Number>
- java.lang.Object
-
- tech.tablesaw.columns.AbstractColumn<C,T>
-
- tech.tablesaw.api.NumberColumn<C,T>
-
- Type Parameters:
C
- The column typeT
- The (boxed) type of data in the column
- All Implemented Interfaces:
Iterable<T>
,Comparator<T>
,NumericColumn<T>
,Column<T>
,NumberFilters
,NumberMapFunctions
,FilterSpec<Selection>
,NumberFilterSpec<Selection>
- Direct Known Subclasses:
DoubleColumn
,FloatColumn
,IntColumn
,LongColumn
,ShortColumn
public abstract class NumberColumn<C extends NumberColumn<C,T>,T extends Number> extends AbstractColumn<C,T> implements NumericColumn<T>
An abstract class that provides a partial implementation for columns of numeric data
-
-
Field Summary
Fields Modifier and Type Field Description protected it.unimi.dsi.fastutil.ints.IntComparator
comparator
protected Locale
locale
-
Fields inherited from class tech.tablesaw.columns.AbstractColumn
DEFAULT_ARRAY_SIZE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
NumberColumn(ColumnType type, String name, AbstractColumnParser<T> parser)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract NumericColumn<T>
bottom(int n)
Returns the smallest ("bottom") n values in the column TODO(lwhite): Consider whether this should exclude missingint
byteSize()
Returns the width of a cell in this column, in bytes.int
countMissing()
Returns the count of missing values in this columnprotected abstract C
createCol(String name)
protected abstract C
createCol(String name, int size)
C
emptyCopy()
Returns a copy of the receiver with no data.C
emptyCopy(int rowSize)
Returns an empty copy of the receiver, with its internal storage initialized to the given row size.protected NumberColumnFormatter
getPrintFormatter()
Returns the NumbetPrintFormatter for this column, or nullString
getString(int row)
Returns a string representation of the value at the given row.it.unimi.dsi.fastutil.ints.IntComparator
rowComparator()
Compares the given ints, which refer to the indexes of the doubles in this column, according to the values of the doubles themselvesNumberColumn<C,T>
set(DoublePredicate condition, T newValue)
Sets the value of all elements in this column matching condition to be equal to newValue and returns this columnNumberColumn<C,T>
set(DoublePredicate condition, NumberColumn<C,T> other)
Updates this column where values matching the selection are replaced with the corresponding value from the given columnvoid
setPrintFormatter(NumberFormat format, String missingValueIndicator)
Sets the print formatter to a newColumnFormatter
constructed from the given number format and missing value indicator TODO: make these return the column?void
setPrintFormatter(NumberColumnFormatter formatter)
Sets the print formatter to the argumentabstract NumericColumn<T>
top(int n)
Returns the largest ("top") n values in the column TODO(lwhite): Consider whether this should exclude missing-
Methods inherited from class tech.tablesaw.columns.AbstractColumn
asStringColumn, filter, first, indexOf, inRange, last, lastIndexOf, map, max, min, name, parser, sampleN, sampleX, set, set, setName, setParser, sorted, subset, toString, type
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface tech.tablesaw.columns.Column
allMatch, anyMatch, append, append, append, appendCell, appendCell, appendMissing, appendObj, asBytes, asList, asObjectArray, asSet, clear, columnWidth, contains, count, count, countUnique, equals, filter, first, get, getUnformattedString, indexOf, inRange, isMissing, last, lastIndexOf, map, map, mapInto, max, max, min, min, name, noneMatch, parser, print, reduce, reduce, removeMissing, sampleN, sampleX, set, set, set, set, set, set, setMissing, setMissingTo, setName, setParser, size, sortAscending, sortDescending, sorted, subset, title, type, unique, valueHash
-
Methods inherited from interface java.util.Comparator
compare, equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Methods inherited from interface tech.tablesaw.columns.numbers.NumberFilters
isBetweenExclusive, isBetweenInclusive, isCloseTo, isEqualTo, isEqualTo, isGreaterThan, isGreaterThan, isGreaterThanOrEqualTo, isGreaterThanOrEqualTo, isLessThan, isLessThan, isLessThanOrEqualTo, isLessThanOrEqualTo, isNegative, isNonNegative, isNotEqualTo, isNotEqualTo, isPositive, isZero, size
-
Methods inherited from interface tech.tablesaw.columns.numbers.NumberMapFunctions
abs, add, add, add, asPercent, asRatio, bin, cube, cubeRoot, cumMax, cumMin, cumProd, cumSum, difference, divide, divide, divide, isMissing, log10, log1p, logN, multiply, multiply, multiply, name, neg, normalize, pctChange, power, power, reciprocal, remainder, remainder, round, roundInt, size, sqrt, square, subtract, subtract, subtract
-
Methods inherited from interface tech.tablesaw.api.NumericColumn
allMatch, anyMatch, asDoubleArray, asDoubleColumn, asFloatColumn, asIntColumn, asLongColumn, asShortColumn, asStringColumn, autoCorrelation, autoCorrelation, copy, count, count, eval, eval, geometricMean, getDouble, interpolate, isEmpty, isIn, isMissing, isNotIn, isNotMissing, kendalls, kurtosis, lag, lead, mapInto, max, max, mean, median, min, min, noneMatch, pctChange, pearsons, percentile, populationVariance, product, quadraticMean, quartile1, quartile3, range, reduce, reduce, rolling, skewness, spearmans, standardDeviation, stats, sum, summarize, summary, sumOfLogs, sumOfSquares, variance, where
-
-
-
-
Field Detail
-
locale
protected Locale locale
-
comparator
protected final it.unimi.dsi.fastutil.ints.IntComparator comparator
-
-
Constructor Detail
-
NumberColumn
protected NumberColumn(ColumnType type, String name, AbstractColumnParser<T> parser)
-
-
Method Detail
-
set
public NumberColumn<C,T> set(DoublePredicate condition, NumberColumn<C,T> other)
Updates this column where values matching the selection are replaced with the corresponding value from the given column
-
set
public NumberColumn<C,T> set(DoublePredicate condition, T newValue)
Sets the value of all elements in this column matching condition to be equal to newValue and returns this column
-
setPrintFormatter
public void setPrintFormatter(NumberFormat format, String missingValueIndicator)
Sets the print formatter to a newColumnFormatter
constructed from the given number format and missing value indicator TODO: make these return the column?- Specified by:
setPrintFormatter
in interfaceNumericColumn<C extends NumberColumn<C,T>>
-
setPrintFormatter
public void setPrintFormatter(NumberColumnFormatter formatter)
Sets the print formatter to the argument- Specified by:
setPrintFormatter
in interfaceNumericColumn<C extends NumberColumn<C,T>>
-
getPrintFormatter
protected NumberColumnFormatter getPrintFormatter()
Returns the NumbetPrintFormatter for this column, or null
-
top
public abstract NumericColumn<T> top(int n)
Returns the largest ("top") n values in the column TODO(lwhite): Consider whether this should exclude missing- Parameters:
n
- The maximum number of records to return. The actual number will be smaller if n is greater than the number of observations in the column- Returns:
- A list, possibly empty, of the largest observations
-
bottom
public abstract NumericColumn<T> bottom(int n)
Returns the smallest ("bottom") n values in the column TODO(lwhite): Consider whether this should exclude missing- Parameters:
n
- The maximum number of records to return. The actual number will be smaller if n is greater than the number of observations in the column- Returns:
- A list, possibly empty, of the smallest n observations
-
getString
public String getString(int row)
Returns a string representation of the value at the given row.
-
emptyCopy
public C emptyCopy()
Returns a copy of the receiver with no data. The column name and type are the same.- Specified by:
emptyCopy
in interfaceColumn<C extends NumberColumn<C,T>>
- Specified by:
emptyCopy
in classAbstractColumn<C extends NumberColumn<C,T>,T extends Number>
- Returns:
- a empty copy of
Column
-
emptyCopy
public C emptyCopy(int rowSize)
Returns an empty copy of the receiver, with its internal storage initialized to the given row size.
-
rowComparator
public it.unimi.dsi.fastutil.ints.IntComparator rowComparator()
Compares the given ints, which refer to the indexes of the doubles in this column, according to the values of the doubles themselves- Specified by:
rowComparator
in interfaceColumn<C extends NumberColumn<C,T>>
-
byteSize
public int byteSize()
Returns the width of a cell in this column, in bytes.
-
countMissing
public int countMissing()
Returns the count of missing values in this column- Specified by:
countMissing
in interfaceColumn<C extends NumberColumn<C,T>>
- Returns:
- missing values as int
-
-