Interface NumericColumn<T extends Number>
-
- Type Parameters:
T
-
- All Superinterfaces:
Column<T>
,Comparator<T>
,FilterSpec<Selection>
,Iterable<T>
,NumberFilters
,NumberFilterSpec<Selection>
,NumberMapFunctions
- All Known Implementing Classes:
DoubleColumn
,FloatColumn
,IntColumn
,LongColumn
,NumberColumn
,ShortColumn
public interface NumericColumn<T extends Number> extends Column<T>, NumberMapFunctions, NumberFilters
A Column of numeric values
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default boolean
allMatch(DoublePredicate test)
Returns true if all rows satisfy the predicate, false otherwisedefault boolean
anyMatch(DoublePredicate test)
Returns true if any row satisfies the predicate, false otherwisedefault double[]
asDoubleArray()
default DoubleColumn
asDoubleColumn()
Returns a new DoubleColumn containing a value for each value in this columndefault FloatColumn
asFloatColumn()
Returns a new FloatColumn containing a value for each value in this columndefault IntColumn
asIntColumn()
Returns a new IntColumn containing a value for each value in this columndefault LongColumn
asLongColumn()
Returns a new LongColumn containing a value for each value in this columndefault ShortColumn
asShortColumn()
Returns a new ShortColumn containing a value for each value in this columnStringColumn
asStringColumn()
Returns a StringColumn consisting of the (unformatted) String representation of this column valuesdefault double
autoCorrelation()
Returns the auto-correlation (correlation between each element and the next)default double
autoCorrelation(int lag)
Returns the auto-correlation between elements separated bylag
.NumericColumn<T>
copy()
Returns a deep copy of the receiverdefault int
count(DoublePredicate test)
Counts the number of rows satisfying predicatedefault int
count(DoublePredicate test, int max)
Counts the number of rows satisfying predicate, but only upto the max valuedefault Selection
eval(BiPredicate<Number,Number> predicate, Number number)
default Selection
eval(DoublePredicate predicate)
default double
geometricMean()
Returns the geometric mean of the data in this columndouble
getDouble(int index)
Returns a double representation of the number atindex
default NumberInterpolator<T>
interpolate()
Returns aNumberInterpolator
object that can be used to interpolate values for elements missing in the columndefault boolean
isEmpty()
Returns true if the column has no datadefault Selection
isIn(Collection<Number> numbers)
default Selection
isMissing()
Returns a selection containing an index for every missing value in this columndefault Selection
isNotIn(Collection<Number> numbers)
default Selection
isNotMissing()
Returns a selection containing an index for every non-missing value in this columndefault double
kendalls(NumericColumn<?> otherColumn)
Returns the Kendall's Tau Rank correlation between the receiver and the otherColumndefault double
kurtosis()
Returns the kurtosis of the data in this columnNumericColumn<T>
lag(int n)
Returns a column of the same type and size as the receiver, containing the receivers values offset by n.default NumericColumn<T>
lead(int n)
Returns a column of the same type as the receiver, containing the receivers values offset -n For example if you lead a column containing 2, 3, 4 by 1, you get a column containing 3, 4, NA.default <R extends Column<RT>,RT>
RmapInto(DoubleFunction<? extends RT> fun, R into)
Maps the function across all rows, appending the results to the provided Columndefault double
max()
Returns the largest value in this columndefault Optional<Double>
max(it.unimi.dsi.fastutil.doubles.DoubleComparator comp)
Returns the maximum row according to the provided Comparatordefault double
mean()
Returns the mean of the data in this columndefault double
median()
Returns the median or 50th percentile of the data in this columndefault double
min()
Returns the smallest value in this columndefault Optional<Double>
min(it.unimi.dsi.fastutil.doubles.DoubleComparator comp)
Returns the minimum row according to the provided Comparatordefault boolean
noneMatch(DoublePredicate test)
Returns true if no row satisfies the predicate, false otherwisedefault DoubleColumn
pctChange(int periods)
Returns a column containing the percentage change between values that areperiods
apartdefault double
pearsons(NumericColumn<?> otherColumn)
Returns the pearson's correlation between the receiver and the otherColumndefault double
percentile(double percentile)
Returns the given percentile of the data in this columndefault double
populationVariance()
Returns the population variance of the data in this columndefault double
product()
Returns the product of values in this columndefault double
quadraticMean()
Returns the quadraticMean, aka the root-mean-square, for all values in this columndefault double
quartile1()
Returns the 1st quartile of the data in this columndefault double
quartile3()
Returns the 3rd quartile of the data in this columndefault double
range()
Returns the range of the data in this columndefault double
reduce(double initial, DoubleBinaryOperator op)
Reduction with binary operator and initial valuedefault Optional<Double>
reduce(DoubleBinaryOperator op)
Reduction with binary operatordefault NumberRollingColumn
rolling(int windowSize)
Returns aRollingColumn
with the given windowSize, which can be used for performing calculations on rolling subsets of my datavoid
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 argumentdefault double
skewness()
Returns the skewness of the data in this columndefault double
spearmans(NumericColumn<?> otherColumn)
Returns the Spearman's Rank correlation between the receiver and the otherColumndefault double
standardDeviation()
Returns the standard deviation of the data in this columndefault Stats
stats()
Returns aStats
object that collects common statistical measures of the data in this columndefault double
sum()
Returns the sum of the values in this columndefault Double
summarize(Selection selection, NumericAggregateFunction function)
Summarizes the data in this column for all rows where the current value matches the selection criteriadefault Table
summary()
Returns a table of common statistical values that together describe the data in this columndefault double
sumOfLogs()
Returns the sum of logs of the data in this columndefault double
sumOfSquares()
Returns the sum of squares of the data in this columndefault double
variance()
Returns the sample variance of the data in this columndefault NumericColumn<T>
where(Selection selection)
Returns the subset of data in this column included in the givenSelection
-
Methods inherited from interface tech.tablesaw.columns.Column
allMatch, anyMatch, append, append, append, appendCell, appendCell, appendMissing, appendObj, asBytes, asList, asObjectArray, asSet, byteSize, clear, columnWidth, contains, count, count, countMissing, countUnique, emptyCopy, emptyCopy, equals, filter, first, get, getString, getUnformattedString, indexOf, inRange, isMissing, last, lastIndexOf, map, map, mapInto, max, max, min, min, name, noneMatch, parser, print, reduce, reduce, removeMissing, rowComparator, 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
-
-
-
-
Method Detail
-
isEmpty
default boolean isEmpty()
Returns true if the column has no data
-
asDoubleArray
default double[] asDoubleArray()
- Specified by:
asDoubleArray
in interfaceNumberMapFunctions
-
eval
default Selection eval(DoublePredicate predicate)
- Specified by:
eval
in interfaceNumberFilters
-
eval
default Selection eval(BiPredicate<Number,Number> predicate, Number number)
- Specified by:
eval
in interfaceNumberFilters
-
isIn
default Selection isIn(Collection<Number> numbers)
- Specified by:
isIn
in interfaceNumberFilters
- Specified by:
isIn
in interfaceNumberFilterSpec<T extends Number>
-
isNotIn
default Selection isNotIn(Collection<Number> numbers)
- Specified by:
isNotIn
in interfaceNumberFilters
- Specified by:
isNotIn
in interfaceNumberFilterSpec<T extends Number>
-
isMissing
default Selection isMissing()
Returns a selection containing an index for every missing value in this column- Specified by:
isMissing
in interfaceColumn<T extends Number>
- Specified by:
isMissing
in interfaceFilterSpec<T extends Number>
- Specified by:
isMissing
in interfaceNumberFilters
-
isNotMissing
default Selection isNotMissing()
Returns a selection containing an index for every non-missing value in this column- Specified by:
isNotMissing
in interfaceColumn<T extends Number>
- Specified by:
isNotMissing
in interfaceFilterSpec<T extends Number>
- Specified by:
isNotMissing
in interfaceNumberFilters
-
count
default int count(DoublePredicate test)
Counts the number of rows satisfying predicate- Parameters:
test
- the predicate- Returns:
- the number of rows satisfying the predicate
-
count
default int count(DoublePredicate test, int max)
Counts the number of rows satisfying predicate, but only upto the max value- Parameters:
test
- the predicatemax
- the maximum number of rows to count- Returns:
- the number of rows satisfying the predicate
-
allMatch
default boolean allMatch(DoublePredicate test)
Returns true if all rows satisfy the predicate, false otherwise- Parameters:
test
- the predicate- Returns:
- true if all rows satisfy the predicate, false otherwise
-
anyMatch
default boolean anyMatch(DoublePredicate test)
Returns true if any row satisfies the predicate, false otherwise- Parameters:
test
- the predicate- Returns:
- true if any rows satisfies the predicate, false otherwise
-
noneMatch
default boolean noneMatch(DoublePredicate test)
Returns true if no row satisfies the predicate, false otherwise- Parameters:
test
- the predicate- Returns:
- true if no row satisfies the predicate, false otherwise
-
max
default Optional<Double> max(it.unimi.dsi.fastutil.doubles.DoubleComparator comp)
Returns the maximum row according to the provided Comparator
-
min
default Optional<Double> min(it.unimi.dsi.fastutil.doubles.DoubleComparator comp)
Returns the minimum row according to the provided Comparator
-
setPrintFormatter
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?
-
setPrintFormatter
void setPrintFormatter(NumberColumnFormatter formatter)
Sets the print formatter to the argument
-
reduce
default double reduce(double initial, DoubleBinaryOperator op)
Reduction with binary operator and initial value- Parameters:
initial
- initial valueop
- the operator- Returns:
- the result of reducing initial value and all rows with operator
-
reduce
default Optional<Double> reduce(DoubleBinaryOperator op)
Reduction with binary operator- Parameters:
op
- the operator- Returns:
- Optional with the result of reducing all rows with operator
-
mapInto
default <R extends Column<RT>,RT> R mapInto(DoubleFunction<? extends RT> fun, R into)
Maps the function across all rows, appending the results to the provided Column- Parameters:
fun
- function to mapinto
- Column to which results are appended- Returns:
- the provided Column, to which results are appended
-
where
default NumericColumn<T> where(Selection selection)
Returns the subset of data in this column included in the givenSelection
-
interpolate
default NumberInterpolator<T> interpolate()
Returns aNumberInterpolator
object that can be used to interpolate values for elements missing in the column- Specified by:
interpolate
in interfaceColumn<T extends Number>
-
summarize
default Double summarize(Selection selection, NumericAggregateFunction function)
Summarizes the data in this column for all rows where the current value matches the selection criteriaExample: myColumn.summarize(myColumn.isLessThan(100), AggregateFunctions.count);
-
sum
default double sum()
Returns the sum of the values in this column- Specified by:
sum
in interfaceNumberMapFunctions
-
product
default double product()
Returns the product of values in this column
-
mean
default double mean()
Returns the mean of the data in this column
-
median
default double median()
Returns the median or 50th percentile of the data in this column
-
quartile1
default double quartile1()
Returns the 1st quartile of the data in this column
-
quartile3
default double quartile3()
Returns the 3rd quartile of the data in this column
-
percentile
default double percentile(double percentile)
Returns the given percentile of the data in this column
-
range
default double range()
Returns the range of the data in this column
-
max
default double max()
Returns the largest value in this column
-
min
default double min()
Returns the smallest value in this column
-
variance
default double variance()
Returns the sample variance of the data in this column
-
populationVariance
default double populationVariance()
Returns the population variance of the data in this column
-
standardDeviation
default double standardDeviation()
Returns the standard deviation of the data in this column
-
sumOfLogs
default double sumOfLogs()
Returns the sum of logs of the data in this column
-
sumOfSquares
default double sumOfSquares()
Returns the sum of squares of the data in this column
-
geometricMean
default double geometricMean()
Returns the geometric mean of the data in this column
-
quadraticMean
default double quadraticMean()
Returns the quadraticMean, aka the root-mean-square, for all values in this column
-
kurtosis
default double kurtosis()
Returns the kurtosis of the data in this column
-
skewness
default double skewness()
Returns the skewness of the data in this column
-
pearsons
default double pearsons(NumericColumn<?> otherColumn)
Returns the pearson's correlation between the receiver and the otherColumn
-
autoCorrelation
default double autoCorrelation()
Returns the auto-correlation (correlation between each element and the next)
-
autoCorrelation
default double autoCorrelation(int lag)
Returns the auto-correlation between elements separated bylag
. If lag is 2, the correlation is computed between pairs of elements 0 and 2, 1 and 3; 2 and 4, etc.
-
spearmans
default double spearmans(NumericColumn<?> otherColumn)
Returns the Spearman's Rank correlation between the receiver and the otherColumn- Parameters:
otherColumn
- A NumberColumn with no missing values- Throws:
org.apache.commons.math3.exception.NotANumberException
- if either column contains any missing values
-
kendalls
default double kendalls(NumericColumn<?> otherColumn)
Returns the Kendall's Tau Rank correlation between the receiver and the otherColumn
-
summary
default Table summary()
Returns a table of common statistical values that together describe the data in this column
-
stats
default Stats stats()
Returns aStats
object that collects common statistical measures of the data in this column
-
rolling
default NumberRollingColumn rolling(int windowSize)
Returns aRollingColumn
with the given windowSize, which can be used for performing calculations on rolling subsets of my data
-
pctChange
default DoubleColumn pctChange(int periods)
Returns a column containing the percentage change between values that areperiods
apart
-
lead
default NumericColumn<T> lead(int n)
Returns a column of the same type as the receiver, containing the receivers values offset -n For example if you lead a column containing 2, 3, 4 by 1, you get a column containing 3, 4, NA.
-
lag
NumericColumn<T> lag(int n)
Returns a column of the same type and size as the receiver, containing the receivers values offset by n.For example if you lag a column containing 2, 3, 4 by 1, you get a column containing NA, 2, 3
-
getDouble
double getDouble(int index)
Returns a double representation of the number atindex
- Specified by:
getDouble
in interfaceNumberFilters
- Specified by:
getDouble
in interfaceNumberMapFunctions
-
asLongColumn
default LongColumn asLongColumn()
Returns a new LongColumn containing a value for each value in this columnThe exact behavior when overridden depends on the type of the receiver (LongColumn, FloatColumn, etc.)
In this version, the result is a copy of the original
-
asIntColumn
default IntColumn asIntColumn()
Returns a new IntColumn containing a value for each value in this columnThe exact behavior when overridden depends on the type of the receiver (LongColumn, FloatColumn, etc.)
In this version, the result is a copy of the original
-
asFloatColumn
default FloatColumn asFloatColumn()
Returns a new FloatColumn containing a value for each value in this columnThe exact behavior when overridden depends on the type of the receiver (LongColumn, FloatColumn, etc.)
In this version, the result is a copy of the original
-
asDoubleColumn
default DoubleColumn asDoubleColumn()
Returns a new DoubleColumn containing a value for each value in this columnThe exact behavior when overridden depends on the type of the receiver (LongColumn, FloatColumn, etc.)
In this version, the result is a copy of the original
-
asShortColumn
default ShortColumn asShortColumn()
Returns a new ShortColumn containing a value for each value in this columnThe exact behavior when overridden depends on the type of the receiver (LongColumn, FloatColumn, etc.)
In this version, the result is a copy of the original
-
copy
NumericColumn<T> copy()
Returns a deep copy of the receiver
-
asStringColumn
StringColumn asStringColumn()
Returns a StringColumn consisting of the (unformatted) String representation of this column values- Specified by:
asStringColumn
in interfaceColumn<T extends Number>
- Returns:
- a
StringColumn
built using the columnColumn.getUnformattedString(int)
method
-
-