Class DoubleColumn
- java.lang.Object
-
- tech.tablesaw.columns.AbstractColumn<C,T>
-
- tech.tablesaw.api.NumberColumn<DoubleColumn,Double>
-
- tech.tablesaw.api.DoubleColumn
-
- All Implemented Interfaces:
Iterable<Double>
,Comparator<Double>
,NumericColumn<Double>
,Column<Double>
,NumberFillers<DoubleColumn>
,NumberFilters
,NumberMapFunctions
,FilterSpec<Selection>
,NumberFilterSpec<Selection>
public class DoubleColumn extends NumberColumn<DoubleColumn,Double> implements NumberFillers<DoubleColumn>
A column that contains double values
-
-
Field Summary
Fields Modifier and Type Field Description protected it.unimi.dsi.fastutil.doubles.DoubleArrayList
data
-
Fields inherited from class tech.tablesaw.api.NumberColumn
comparator, locale
-
Fields inherited from class tech.tablesaw.columns.AbstractColumn
DEFAULT_ARRAY_SIZE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DoubleColumn(String name)
protected
DoubleColumn(String name, it.unimi.dsi.fastutil.doubles.DoubleArrayList data)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DoubleColumn
append(double d)
Adds the given double to this columnDoubleColumn
append(float f)
Adds the given float to this columnDoubleColumn
append(int i)
DoubleColumn
append(Double val)
Appends value to the bottom of this column and return this columnDoubleColumn
append(Number val)
DoubleColumn
append(Column<Double> column)
Appends all the values in the argument to the bottom of this column and return this columnDoubleColumn
append(Column<Double> column, int row)
Appends the value at the given row in the given column to the bottom of this column and return this columnDoubleColumn
appendCell(String value)
Add one element to the bottom of this column and set its value to the parsed value of the given String.DoubleColumn
appendCell(String value, AbstractColumnParser<?> parser)
Add one element to the bottom of this column and set its value to the parsed value of the given String, as performed by the given parserDoubleColumn
appendMissing()
Appends a missing value appropriate to the columnDoubleColumn
appendObj(Object obj)
Appends the given value to the bottom of this column and return this columnbyte[]
asBytes(int rowNumber)
Returns the contents of the cell at rowNumber as a byte[].double[]
asDoubleArray()
FloatColumn
asFloatColumn()
Returns a new FloatColumn containing a value for each value in this column, truncating if necessary.IntColumn
asIntColumn()
Returns a new IntColumn containing a value for each value in this column, truncating if necessary.LongColumn
asLongColumn()
Returns a new LongColumn containing a value for each value in this column, truncating if necessaryDouble[]
asObjectArray()
Returns an array of objects as appropriate for my type of columnSet<Double>
asSet()
Returns a Set containing all the unique values in this columnShortColumn
asShortColumn()
Returns a new ShortColumn containing a value for each value in this column, truncating if necessary.DoubleColumn
bottom(int n)
Returns the smallest ("bottom") n values in the column TODO(lwhite): Consider whether this should exclude missingvoid
clear()
Removes all elements TODO: Make this return this columnint
compare(Double o1, Double o2)
DoubleColumn
copy()
Returns a deep copy of the receiverint
countUnique()
Returns the count of unique values in this column.static DoubleColumn
create(String name)
static DoubleColumn
create(String name, double... arr)
static DoubleColumn
create(String name, float... arr)
static DoubleColumn
create(String name, int initialSize)
static DoubleColumn
create(String name, int... arr)
static DoubleColumn
create(String name, long... arr)
static DoubleColumn
create(String name, Number[] numbers)
static DoubleColumn
create(String name, Collection<? extends Number> numberList)
static DoubleColumn
create(String name, DoubleStream stream)
DoubleColumn
createCol(String name)
DoubleColumn
createCol(String name, int initialSize)
boolean
equals(int rowNumber1, int rowNumber2)
Returns true if the value in this column at rowNumber1 is equal to the value at rowNumber2DoubleColumn
fillWith(double d)
DoubleColumn
fillWith(it.unimi.dsi.fastutil.doubles.DoubleIterator iterator)
DoubleColumn
fillWith(DoubleSupplier supplier)
DoubleColumn
fillWith(DoubleRangeIterable iterable)
DoubleColumn
filter(DoublePredicate test)
Returns a new NumberColumn with only those rows satisfying the predicateDouble
get(int index)
Returns the value at the given zero-based indexdouble
getDouble(int row)
Returns a double representation of the number atindex
String
getString(int row)
Returns a string representation of the value at the given row.String
getUnformattedString(int row)
Returns a String representation of the value at index r, without any formatting appliedSelection
isIn(double... doubles)
boolean
isMissing(int rowNumber)
Returns true if the value at rowNumber is missingboolean
isMissingValue(double value)
Selection
isNotIn(double... doubles)
Iterator<Double>
iterator()
DoubleColumn
lag(int n)
Returns a column of the same type and size as the receiver, containing the receivers values offset by n.DoubleColumn
removeMissing()
Returns a copy of this column with the missing values removedDoubleColumn
set(int i, double val)
DoubleColumn
set(int i, Double val)
Sets the value at index row to the given value and return this columnColumn<Double>
set(int row, String stringValue, AbstractColumnParser<?> parser)
Sets the value at row to the parsed value of the given String using the given parser and returns this columnDoubleColumn
set(int row, Column<Double> column, int sourceRow)
Sets the value at row to the value at sourceRow in the given column and return this columnDoubleColumn
set(DoublePredicate condition, NumericColumn<?> other)
Updates this column where values matching the selection are replaced with the corresponding value from the given columnDoubleColumn
setMissing(int index)
Sets the value at index i to the missing-value indicator for this column type, and return this columnint
size()
Returns the number of elements in this column, including missing valuesvoid
sortAscending()
Sorts my values in ascending ordervoid
sortDescending()
Sorts my values in descending orderDoubleColumn
subset(int[] rows)
Return a column of the same type containing just those elements whose indexes are included in the given arrayDoubleColumn
top(int n)
Returns the largest ("top") n values in the column TODO(lwhite): Consider whether this should exclude missingDoubleColumn
unique()
Returns a column of the same type containing only the unique valuesint
valueHash(int rowNumber)
Returns an int suitable as a hash for the value in this column at the given indexstatic boolean
valueIsMissing(double value)
DoubleColumn
where(Selection selection)
Returns the subset of data in this column included in the givenSelection
-
Methods inherited from class tech.tablesaw.api.NumberColumn
byteSize, countMissing, emptyCopy, emptyCopy, getPrintFormatter, rowComparator, set, set, setPrintFormatter, setPrintFormatter
-
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, 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, asList, columnWidth, contains, count, count, filter, first, indexOf, inRange, last, lastIndexOf, map, map, mapInto, max, max, min, min, name, noneMatch, parser, print, reduce, reduce, sampleN, sampleX, set, set, set, setMissingTo, setName, setParser, sorted, title, type
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from interface java.lang.Iterable
forEach, 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
-
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, log10, log1p, logN, multiply, multiply, multiply, name, neg, normalize, pctChange, power, power, reciprocal, remainder, remainder, round, roundInt, sqrt, square, subtract, subtract, subtract
-
Methods inherited from interface tech.tablesaw.api.NumericColumn
allMatch, anyMatch, asDoubleColumn, asStringColumn, autoCorrelation, autoCorrelation, count, count, eval, eval, geometricMean, interpolate, isEmpty, isIn, isMissing, isNotIn, isNotMissing, kendalls, kurtosis, 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
-
-
-
-
Method Detail
-
valueIsMissing
public static boolean valueIsMissing(double value)
-
getString
public String getString(int row)
Returns a string representation of the value at the given row.- Specified by:
getString
in interfaceColumn<Double>
- Overrides:
getString
in classNumberColumn<DoubleColumn,Double>
- Parameters:
row
- The index of the row.- Returns:
- value as String
-
size
public int size()
Returns the number of elements in this column, including missing values- Specified by:
size
in interfaceColumn<Double>
- Specified by:
size
in interfaceNumberFilters
- Specified by:
size
in interfaceNumberMapFunctions
-
clear
public void clear()
Removes all elements TODO: Make this return this column
-
setMissing
public DoubleColumn setMissing(int index)
Sets the value at index i to the missing-value indicator for this column type, and return this column- Specified by:
setMissing
in interfaceColumn<Double>
-
create
public static DoubleColumn create(String name, double... arr)
-
create
public static DoubleColumn create(String name)
-
create
public static DoubleColumn create(String name, float... arr)
-
create
public static DoubleColumn create(String name, int... arr)
-
create
public static DoubleColumn create(String name, long... arr)
-
create
public static DoubleColumn create(String name, Collection<? extends Number> numberList)
-
create
public static DoubleColumn create(String name, Number[] numbers)
-
create
public static DoubleColumn create(String name, int initialSize)
-
create
public static DoubleColumn create(String name, DoubleStream stream)
-
createCol
public DoubleColumn createCol(String name, int initialSize)
- Specified by:
createCol
in classNumberColumn<DoubleColumn,Double>
-
createCol
public DoubleColumn createCol(String name)
- Specified by:
createCol
in classNumberColumn<DoubleColumn,Double>
-
get
public Double get(int index)
Returns the value at the given zero-based index
-
where
public DoubleColumn where(Selection selection)
Returns the subset of data in this column included in the givenSelection
-
isNotIn
public Selection isNotIn(double... doubles)
-
isIn
public Selection isIn(double... doubles)
-
subset
public DoubleColumn subset(int[] rows)
Return a column of the same type containing just those elements whose indexes are included in the given array- Specified by:
subset
in interfaceColumn<Double>
- Overrides:
subset
in classAbstractColumn<DoubleColumn,Double>
-
unique
public DoubleColumn unique()
Returns a column of the same type containing only the unique values
-
top
public DoubleColumn top(int n)
Returns the largest ("top") n values in the column TODO(lwhite): Consider whether this should exclude missing- Specified by:
top
in classNumberColumn<DoubleColumn,Double>
- 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 DoubleColumn bottom(int n)
Returns the smallest ("bottom") n values in the column TODO(lwhite): Consider whether this should exclude missing- Specified by:
bottom
in classNumberColumn<DoubleColumn,Double>
- 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
-
lag
public DoubleColumn 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
-
removeMissing
public DoubleColumn removeMissing()
Returns a copy of this column with the missing values removed- Specified by:
removeMissing
in interfaceColumn<Double>
-
append
public DoubleColumn append(float f)
Adds the given float to this column
-
append
public DoubleColumn append(double d)
Adds the given double to this column
-
append
public DoubleColumn append(int i)
-
valueHash
public int valueHash(int rowNumber)
Returns an int suitable as a hash for the value in this column at the given index
-
equals
public boolean equals(int rowNumber1, int rowNumber2)
Returns true if the value in this column at rowNumber1 is equal to the value at rowNumber2
-
append
public DoubleColumn append(Double val)
Appends value to the bottom of this column and return this column
-
append
public DoubleColumn append(Number val)
-
copy
public DoubleColumn copy()
Returns a deep copy of the receiver
-
asDoubleArray
public double[] asDoubleArray()
Description copied from interface:NumericColumn
- Specified by:
asDoubleArray
in interfaceNumberMapFunctions
- Specified by:
asDoubleArray
in interfaceNumericColumn<Double>
-
asObjectArray
public Double[] asObjectArray()
Returns an array of objects as appropriate for my type of column- Specified by:
asObjectArray
in interfaceColumn<Double>
-
compare
public int compare(Double o1, Double o2)
- Specified by:
compare
in interfaceComparator<Double>
-
set
public DoubleColumn set(int i, Double val)
Sets the value at index row to the given value and return this column
-
set
public DoubleColumn set(int i, double val)
-
set
public DoubleColumn set(DoublePredicate condition, NumericColumn<?> other)
Updates this column where values matching the selection are replaced with the corresponding value from the given column
-
set
public Column<Double> set(int row, String stringValue, AbstractColumnParser<?> parser)
Sets the value at row to the parsed value of the given String using the given parser and returns this column
-
append
public DoubleColumn append(Column<Double> column)
Appends all the values in the argument to the bottom of this column and return this column
-
append
public DoubleColumn append(Column<Double> column, int row)
Appends the value at the given row in the given column to the bottom of this column and return this column
-
set
public DoubleColumn set(int row, Column<Double> column, int sourceRow)
Sets the value at row to the value at sourceRow in the given column and return this column
-
filter
public DoubleColumn filter(DoublePredicate test)
Returns a new NumberColumn with only those rows satisfying the predicate- Parameters:
test
- the predicate- Returns:
- a new NumberColumn with only those rows satisfying the predicate
-
asBytes
public byte[] asBytes(int rowNumber)
Returns the contents of the cell at rowNumber as a byte[].
-
countUnique
public int countUnique()
Returns the count of unique values in this column.- Specified by:
countUnique
in interfaceColumn<Double>
- Returns:
- unique values as int
-
getDouble
public double getDouble(int row)
Returns a double representation of the number atindex
- Specified by:
getDouble
in interfaceNumberFilters
- Specified by:
getDouble
in interfaceNumberMapFunctions
- Specified by:
getDouble
in interfaceNumericColumn<Double>
-
isMissingValue
public boolean isMissingValue(double value)
-
isMissing
public boolean isMissing(int rowNumber)
Returns true if the value at rowNumber is missing- Specified by:
isMissing
in interfaceColumn<Double>
- Specified by:
isMissing
in interfaceNumberMapFunctions
-
sortAscending
public void sortAscending()
Sorts my values in ascending order- Specified by:
sortAscending
in interfaceColumn<Double>
-
sortDescending
public void sortDescending()
Sorts my values in descending order- Specified by:
sortDescending
in interfaceColumn<Double>
-
appendMissing
public DoubleColumn appendMissing()
Appends a missing value appropriate to the column- Specified by:
appendMissing
in interfaceColumn<Double>
-
appendObj
public DoubleColumn appendObj(Object obj)
Appends the given value to the bottom of this column and return this column
-
appendCell
public DoubleColumn appendCell(String value)
Add one element to the bottom of this column and set its value to the parsed value of the given String. Parsing is type-specific- Specified by:
appendCell
in interfaceColumn<Double>
-
appendCell
public DoubleColumn appendCell(String value, AbstractColumnParser<?> parser)
Add one element to the bottom of this column and set its value to the parsed value of the given String, as performed by the given parser- Specified by:
appendCell
in interfaceColumn<Double>
-
getUnformattedString
public String getUnformattedString(int row)
Returns a String representation of the value at index r, without any formatting applied- Specified by:
getUnformattedString
in interfaceColumn<Double>
-
fillWith
public DoubleColumn fillWith(it.unimi.dsi.fastutil.doubles.DoubleIterator iterator)
- Specified by:
fillWith
in interfaceNumberFillers<DoubleColumn>
-
fillWith
public DoubleColumn fillWith(DoubleRangeIterable iterable)
- Specified by:
fillWith
in interfaceNumberFillers<DoubleColumn>
-
fillWith
public DoubleColumn fillWith(DoubleSupplier supplier)
- Specified by:
fillWith
in interfaceNumberFillers<DoubleColumn>
-
fillWith
public DoubleColumn fillWith(double d)
- Specified by:
fillWith
in interfaceNumberFillers<DoubleColumn>
-
asLongColumn
public LongColumn asLongColumn()
Returns a new LongColumn containing a value for each value in this column, truncating if necessaryA narrowing primitive conversion such as this one may lose information about the overall magnitude of a numeric value and may also lose precision and range. Specifically, if the value is too small (a negative value of large magnitude or negative infinity), the result is the smallest representable value of type long.
Similarly, if the value is too large (a positive value of large magnitude or positive infinity), the result is the largest representable value of type long.
Despite the fact that overflow, underflow, or other loss of information may occur, a narrowing primitive conversion never results in a run-time exception.
A missing value in the receiver is converted to a missing value in the result
- Specified by:
asLongColumn
in interfaceNumericColumn<Double>
-
asIntColumn
public IntColumn asIntColumn()
Returns a new IntColumn containing a value for each value in this column, truncating if necessary.A narrowing primitive conversion such as this one may lose information about the overall magnitude of a numeric value and may also lose precision and range. Specifically, if the value is too small (a negative value of large magnitude or negative infinity), the result is the smallest representable value of type int.
Similarly, if the value is too large (a positive value of large magnitude or positive infinity), the result is the largest representable value of type int.
Despite the fact that overflow, underflow, or other loss of information may occur, a narrowing primitive conversion never results in a run-time exception.
A missing value in the receiver is converted to a missing value in the result
- Specified by:
asIntColumn
in interfaceNumericColumn<Double>
-
asShortColumn
public ShortColumn asShortColumn()
Returns a new ShortColumn containing a value for each value in this column, truncating if necessary.A narrowing primitive conversion such as this one may lose information about the overall magnitude of a numeric value and may also lose precision and range. Specifically, if the value is too small (a negative value of large magnitude or negative infinity), the result is the smallest representable value of type int.
Similarly, if the value is too large (a positive value of large magnitude or positive infinity), the result is the largest representable value of type short.
Despite the fact that overflow, underflow, or other loss of information may occur, a narrowing primitive conversion never results in a run-time exception.
A missing value in the receiver is converted to a missing value in the result
- Specified by:
asShortColumn
in interfaceNumericColumn<Double>
-
asFloatColumn
public FloatColumn asFloatColumn()
Returns a new FloatColumn containing a value for each value in this column, truncating if necessary.A narrowing primitive conversion such as this one may lose information about the overall magnitude of a numeric value and may also lose precision and range. Specifically, if the value is too small (a negative value of large magnitude or negative infinity), the result is the smallest representable value of type float.
Similarly, if the value is too large (a positive value of large magnitude or positive infinity), the result is the largest representable value of type float.
Despite the fact that overflow, underflow, or other loss of information may occur, a narrowing primitive conversion never results in a run-time exception.
A missing value in the receiver is converted to a missing value in the result
- Specified by:
asFloatColumn
in interfaceNumericColumn<Double>
-
-