Class LongColumn
- java.lang.Object
-
- tech.tablesaw.columns.AbstractColumn<C,T>
-
- tech.tablesaw.api.NumberColumn<LongColumn,Long>
-
- tech.tablesaw.api.LongColumn
-
- All Implemented Interfaces:
Iterable<Long>
,Comparator<Long>
,CategoricalColumn<Long>
,NumericColumn<Long>
,Column<Long>
,NumberFilters
,NumberMapFunctions
,FilterSpec<Selection>
,NumberFilterSpec<Selection>
public class LongColumn extends NumberColumn<LongColumn,Long> implements CategoricalColumn<Long>
A column that contains long values
-
-
Field Summary
Fields Modifier and Type Field Description protected it.unimi.dsi.fastutil.longs.LongArrayList
data
-
Fields inherited from class tech.tablesaw.api.NumberColumn
comparator, locale
-
Fields inherited from class tech.tablesaw.columns.AbstractColumn
DEFAULT_ARRAY_SIZE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LongColumn
append(long i)
LongColumn
append(Long val)
Appends value to the bottom of this column and return this columnLongColumn
append(Column<Long> column)
Appends all the values in the argument to the bottom of this column and return this columnLongColumn
append(Column<Long> column, int row)
Appends the value at the given row in the given column to the bottom of this column and return this columnLongColumn
appendCell(String value)
Add one element to the bottom of this column and set its value to the parsed value of the given String.LongColumn
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 parserLongColumn
appendMissing()
Appends a missing value appropriate to the columnLongColumn
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[].DateTimeColumn
asDateTimes(ZoneOffset offset)
Returns a DateTimeColumn where each value is the LocalDateTime represented by the values in this columnDoubleColumn
asDoubleColumn()
Returns a new DoubleColumn containing a value for each value in this columnFloatColumn
asFloatColumn()
Returns a new FloatColumn containing a value for each value in this columnIntColumn
asIntColumn()
Returns a new IntColumn containing a value for each value in this columnlong[]
asLongArray()
Long[]
asObjectArray()
Returns an array of objects as appropriate for my type of columnSet<Long>
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 columnLongColumn
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(Long o1, Long o2)
LongColumn
copy()
Returns a deep copy of the receiverTable
countByCategory()
Returns a count of the number of elements in each category (i.e., the number of repetitions of each value) TODO: This needs to be well tested, especially for IntColumnint
countUnique()
Returns the count of unique values in this column.static LongColumn
create(String name)
static LongColumn
create(String name, int initialSize)
static LongColumn
create(String name, long... arr)
static LongColumn
create(String name, LongStream stream)
LongColumn
createCol(String name)
LongColumn
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 rowNumber2Long
get(int index)
Returns the value at the given zero-based indexdouble
getDouble(int row)
Returns a double representation of the number atindex
long
getLong(int row)
Returns the value at the given index.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 appliedstatic LongColumn
indexColumn(String columnName, int size, int startsWith)
Returns a new numeric column initialized with the given name and size.Selection
isIn(long... numbers)
boolean
isMissing(int rowNumber)
Returns true if the value at rowNumber is missingboolean
isMissingValue(long value)
Selection
isNotIn(long... numbers)
Iterator<Long>
iterator()
LongColumn
lag(int n)
Returns a column of the same type and size as the receiver, containing the receivers values offset by n.it.unimi.dsi.fastutil.longs.LongIterator
longIterator()
LongColumn
removeMissing()
Returns a copy of this column with the missing values removedLongColumn
set(int i, long val)
LongColumn
set(int i, Long val)
Sets the value at index row to the given value and return this columnColumn<Long>
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 columnLongColumn
set(int row, Column<Long> column, int sourceRow)
Sets the value at row to the value at sourceRow in the given column and return this columnLongColumn
setMissing(int i)
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 orderLongColumn
subset(int[] rows)
Return a column of the same type containing just those elements whose indexes are included in the given arrayLongColumn
top(int n)
Returns the largest ("top") n values in the column TODO(lwhite): Consider whether this should exclude missingLongColumn
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(long value)
-
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, byteSize, columnWidth, contains, count, count, countMissing, emptyCopy, emptyCopy, filter, first, indexOf, inRange, last, lastIndexOf, map, map, mapInto, max, max, min, min, name, noneMatch, parser, print, reduce, reduce, rowComparator, 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, asDoubleArray, asLongColumn, 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, where
-
-
-
-
Method Detail
-
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
-
create
public static LongColumn create(String name)
-
create
public static LongColumn create(String name, long... arr)
-
create
public static LongColumn create(String name, int initialSize)
-
create
public static LongColumn create(String name, LongStream stream)
-
createCol
public LongColumn createCol(String name, int initialSize)
- Specified by:
createCol
in classNumberColumn<LongColumn,Long>
-
createCol
public LongColumn createCol(String name)
- Specified by:
createCol
in classNumberColumn<LongColumn,Long>
-
indexColumn
public static LongColumn indexColumn(String columnName, int size, int startsWith)
Returns a new numeric column initialized with the given name and size. The values in the column are integers beginning at startsWith and continuing through size (exclusive), monotonically increasing by 1 TODO consider a generic fill function including steps or random samples from various distributions
-
getString
public String getString(int row)
Returns a string representation of the value at the given row.- Specified by:
getString
in interfaceColumn<Long>
- Overrides:
getString
in classNumberColumn<LongColumn,Long>
- Parameters:
row
- The index of the row.- Returns:
- value as String
-
valueIsMissing
public static boolean valueIsMissing(long value)
-
size
public int size()
Returns the number of elements in this column, including missing values- Specified by:
size
in interfaceColumn<Long>
- Specified by:
size
in interfaceNumberFilters
- Specified by:
size
in interfaceNumberMapFunctions
-
clear
public void clear()
Removes all elements TODO: Make this return this column
-
get
public Long get(int index)
Returns the value at the given zero-based index
-
subset
public LongColumn 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<Long>
- Overrides:
subset
in classAbstractColumn<LongColumn,Long>
-
isIn
public Selection isIn(long... numbers)
-
isNotIn
public Selection isNotIn(long... numbers)
-
unique
public LongColumn unique()
Returns a column of the same type containing only the unique values
-
top
public LongColumn 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<LongColumn,Long>
- 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 LongColumn 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<LongColumn,Long>
- 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 LongColumn 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 LongColumn removeMissing()
Returns a copy of this column with the missing values removed- Specified by:
removeMissing
in interfaceColumn<Long>
-
append
public LongColumn append(long i)
-
append
public LongColumn append(Long val)
Appends value to the bottom of this column and return this column
-
copy
public LongColumn copy()
Returns a deep copy of the receiver
-
asLongArray
public long[] asLongArray()
-
asDateTimes
public DateTimeColumn asDateTimes(ZoneOffset offset)
Returns a DateTimeColumn where each value is the LocalDateTime represented by the values in this columnThe values in this column must be longs that represent the time in milliseconds from the epoch as in standard Java date/time calculations
- Parameters:
offset
- The ZoneOffset to use in the calculation- Returns:
- A column of LocalDateTime values
-
longIterator
public it.unimi.dsi.fastutil.longs.LongIterator longIterator()
-
asObjectArray
public Long[] asObjectArray()
Returns an array of objects as appropriate for my type of column- Specified by:
asObjectArray
in interfaceColumn<Long>
-
compare
public int compare(Long o1, Long o2)
- Specified by:
compare
in interfaceComparator<Long>
-
set
public LongColumn set(int i, Long val)
Sets the value at index row to the given value and return this column
-
set
public LongColumn set(int i, long val)
-
set
public Column<Long> 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 LongColumn append(Column<Long> column)
Appends all the values in the argument to the bottom of this column and return this column
-
append
public LongColumn append(Column<Long> 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 LongColumn set(int row, Column<Long> column, int sourceRow)
Sets the value at row to the value at sourceRow in the given column and return this column
-
appendMissing
public LongColumn appendMissing()
Appends a missing value appropriate to the column- Specified by:
appendMissing
in interfaceColumn<Long>
-
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<Long>
- Returns:
- unique values as int
-
getLong
public long getLong(int row)
Returns the value at the given index. The actual value is returned if the ColumnType is INTEGER. Otherwise the value is rounded as described below.Returns the closest
int
to the argument, with ties rounding to positive infinity.Special cases:
Special cases:
- If the argument is NaN, the result is 0.
- If the argument is positive infinity or any value greater than or equal to the value of
Integer.MAX_VALUE
, an error will be thrown
- Parameters:
row
- the index of the value to be rounded to an integer.- Returns:
- the value of the argument rounded to the nearest
int
value. - Throws:
ClassCastException
- if the absolute value of the value to be rounded is too large to be cast to an 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<Long>
-
isMissingValue
public boolean isMissingValue(long value)
-
isMissing
public boolean isMissing(int rowNumber)
Returns true if the value at rowNumber is missing- Specified by:
isMissing
in interfaceColumn<Long>
- Specified by:
isMissing
in interfaceNumberMapFunctions
-
setMissing
public LongColumn setMissing(int i)
Sets the value at index i to the missing-value indicator for this column type, and return this column- Specified by:
setMissing
in interfaceColumn<Long>
-
sortAscending
public void sortAscending()
Sorts my values in ascending order- Specified by:
sortAscending
in interfaceColumn<Long>
-
sortDescending
public void sortDescending()
Sorts my values in descending order- Specified by:
sortDescending
in interfaceColumn<Long>
-
appendObj
public LongColumn appendObj(Object obj)
Appends the given value to the bottom of this column and return this column
-
appendCell
public LongColumn 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<Long>
-
appendCell
public LongColumn 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<Long>
-
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<Long>
-
countByCategory
public Table countByCategory()
Returns a count of the number of elements in each category (i.e., the number of repetitions of each value) TODO: This needs to be well tested, especially for IntColumn- Specified by:
countByCategory
in interfaceCategoricalColumn<Long>
-
asIntColumn
public IntColumn asIntColumn()
Returns a new IntColumn containing a value for each value in this columnA narrowing conversion of a signed integer to an integral type T simply discards all but the n lowest order bits, where n is the number of bits used to represent type T. In addition to a possible loss of information about the magnitude of the numeric value, this may cause the sign of the resulting value to differ from the sign of the input value.
In other words, if the element being converted is larger (or smaller) than Integer.MAX_VALUE (or Integer.MIN_VALUE) you will not get a conventionally good conversion.
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<Long>
-
asShortColumn
public ShortColumn asShortColumn()
Returns a new ShortColumn containing a value for each value in this columnA narrowing conversion of a signed long to an integral type T simply discards all but the n lowest order bits, where n is the number of bits used to represent type T. In addition to a possible loss of information about the magnitude of the numeric value, this may cause the sign of the resulting value to differ from the sign of the input value.
In other words, if the element being converted is larger (or smaller) than Short.MAX_VALUE (or Short.MIN_VALUE) you will not get a conventionally good conversion.
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<Long>
-
asFloatColumn
public FloatColumn asFloatColumn()
Returns a new FloatColumn containing a value for each value in this columnA widening primitive conversion from a long to a float does not lose information about the overall magnitude of a numeric value. It may, however, result in loss of precision - that is, the result may lose some of the least significant bits of the value. In this case, the resulting floating-point value will be a correctly rounded version of the integer value, using IEEE 754 round-to-nearest mode.
Despite the fact that a loss of precision may occur, a widening 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<Long>
-
asDoubleColumn
public DoubleColumn asDoubleColumn()
Returns a new DoubleColumn containing a value for each value in this columnA widening primitive conversion from a long to a double does not lose information about the overall magnitude of a numeric value. It may, however, result in loss of precision - that is, the result may lose some of the least significant bits of the value. In this case, the resulting floating-point value will be a correctly rounded version of the integer value, using IEEE 754 round-to-nearest mode.
Despite the fact that a loss of precision may occur, a widening 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:
asDoubleColumn
in interfaceNumericColumn<Long>
-
-