Class IntColumn
- java.lang.Object
-
- tech.tablesaw.columns.AbstractColumn<C,T>
-
- tech.tablesaw.api.NumberColumn<IntColumn,Integer>
-
- tech.tablesaw.api.IntColumn
-
- All Implemented Interfaces:
Iterable<Integer>,Comparator<Integer>,CategoricalColumn<Integer>,NumericColumn<Integer>,Column<Integer>,NumberFilters,NumberMapFunctions,FilterSpec<Selection>,NumberFilterSpec<Selection>
public class IntColumn extends NumberColumn<IntColumn,Integer> implements CategoricalColumn<Integer>
A column that contains int values
-
-
Field Summary
Fields Modifier and Type Field Description protected it.unimi.dsi.fastutil.ints.IntArrayListdata-
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 IntColumnappend(int i)IntColumnappend(Integer val)Appends value to the bottom of this column and return this columnIntColumnappend(Column<Integer> column)Appends all the values in the argument to the bottom of this column and return this columnIntColumnappend(Column<Integer> column, int row)Appends the value at the given row in the given column to the bottom of this column and return this columnIntColumnappendCell(String value)Add one element to the bottom of this column and set its value to the parsed value of the given String.IntColumnappendCell(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 parserIntColumnappendMissing()Appends a missing value appropriate to the columnIntColumnappendObj(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[].DoubleColumnasDoubleColumn()Returns a new DoubleColumn containing a value for each value in this column, truncating if necessary.FloatColumnasFloatColumn()Returns a new FloatColumn containing a value for each value in this column, truncating if necessary.int[]asIntArray()LongColumnasLongColumn()Returns a new LongColumn containing a value for each value in this columnInteger[]asObjectArray()Returns an array of objects as appropriate for my type of columnSet<Integer>asSet()Returns a Set containing all the unique values in this columnShortColumnasShortColumn()Returns a new ShortColumn containing a value for each value in this columnIntColumnbottom(int n)Returns the smallest ("bottom") n values in the column TODO(lwhite): Consider whether this should exclude missingvoidclear()Removes all elements TODO: Make this return this columnintcompare(Integer o1, Integer o2)IntColumncopy()Returns a deep copy of the receiverintcountUnique()Returns the count of unique values in this column.static IntColumncreate(String name)static IntColumncreate(String name, int initialSize)static IntColumncreate(String name, int... arr)static IntColumncreate(String name, Integer[] arr)static IntColumncreate(String name, IntStream stream)IntColumncreateCol(String name)IntColumncreateCol(String name, int initialSize)booleanequals(int rowNumber1, int rowNumber2)Returns true if the value in this column at rowNumber1 is equal to the value at rowNumber2Integerget(int index)Returns the value at the given zero-based indexdoublegetDouble(int row)Returns a double representation of the number atindexintgetInt(int row)Returns the value at the given index.StringgetString(int row)Returns a string representation of the value at the given row.StringgetUnformattedString(int row)Returns a String representation of the value at index r, without any formatting appliedstatic IntColumnindexColumn(String columnName, int size, int startsWith)Returns a new numeric column initialized with the given name and size.it.unimi.dsi.fastutil.ints.IntIteratorintIterator()SelectionisIn(int... numbers)booleanisMissing(int rowNumber)Returns true if the value at rowNumber is missingbooleanisMissingValue(int value)SelectionisNotIn(int... numbers)SelectionisNotIn(IntColumn ints)Iterator<Integer>iterator()IntColumnlag(int n)Returns a column of the same type and size as the receiver, containing the receivers values offset by n.IntColumnremoveMissing()Returns a copy of this column with the missing values removedIntColumnset(int i, int val)IntColumnset(int i, Integer val)Sets the value at index row to the given value and return this columnColumn<Integer>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 columnIntColumnset(int row, Column<Integer> column, int sourceRow)Sets the value at row to the value at sourceRow in the given column and return this columnIntColumnsetMissing(int r)Sets the value at index i to the missing-value indicator for this column type, and return this columnintsize()Returns the number of elements in this column, including missing valuesvoidsortAscending()Sorts my values in ascending ordervoidsortDescending()Sorts my values in descending orderIntColumnsubset(int[] rows)Return a column of the same type containing just those elements whose indexes are included in the given arrayIntColumntop(int n)Returns the largest ("top") n values in the column TODO(lwhite): Consider whether this should exclude missingIntColumnunique()Returns a column of the same type containing only the unique valuesintvalueHash(int rowNumber)Returns an int suitable as a hash for the value in this column at the given indexstatic booleanvalueIsMissing(int 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.api.CategoricalColumn
countByCategory
-
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, asIntColumn, 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
-
-
-
-
Constructor Detail
-
IntColumn
protected IntColumn(String name, it.unimi.dsi.fastutil.ints.IntArrayList data)
-
-
Method Detail
-
createCol
public IntColumn createCol(String name, int initialSize)
- Specified by:
createColin classNumberColumn<IntColumn,Integer>
-
createCol
public IntColumn createCol(String name)
- Specified by:
createColin classNumberColumn<IntColumn,Integer>
-
indexColumn
public static IntColumn 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
-
size
public int size()
Returns the number of elements in this column, including missing values- Specified by:
sizein interfaceColumn<Integer>- Specified by:
sizein interfaceNumberFilters- Specified by:
sizein interfaceNumberMapFunctions
-
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
-
clear
public void clear()
Removes all elements TODO: Make this return this column
-
valueIsMissing
public static boolean valueIsMissing(int value)
-
get
public Integer get(int index)
Returns the value at the given zero-based index
-
asIntArray
public int[] asIntArray()
-
subset
public IntColumn subset(int[] rows)
Return a column of the same type containing just those elements whose indexes are included in the given array
-
unique
public IntColumn unique()
Returns a column of the same type containing only the unique values
-
top
public IntColumn top(int n)
Returns the largest ("top") n values in the column TODO(lwhite): Consider whether this should exclude missing- Specified by:
topin classNumberColumn<IntColumn,Integer>- 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 IntColumn bottom(int n)
Returns the smallest ("bottom") n values in the column TODO(lwhite): Consider whether this should exclude missing- Specified by:
bottomin classNumberColumn<IntColumn,Integer>- 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 IntColumn 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 IntColumn removeMissing()
Returns a copy of this column with the missing values removed- Specified by:
removeMissingin interfaceColumn<Integer>
-
append
public IntColumn append(int i)
-
append
public IntColumn append(Integer val)
Appends value to the bottom of this column and return this column
-
copy
public IntColumn copy()
Returns a deep copy of the receiver
-
intIterator
public it.unimi.dsi.fastutil.ints.IntIterator intIterator()
-
asObjectArray
public Integer[] asObjectArray()
Returns an array of objects as appropriate for my type of column- Specified by:
asObjectArrayin interfaceColumn<Integer>
-
compare
public int compare(Integer o1, Integer o2)
- Specified by:
comparein interfaceComparator<Integer>
-
set
public IntColumn set(int i, Integer val)
Sets the value at index row to the given value and return this column
-
set
public IntColumn set(int i, int val)
-
append
public IntColumn append(Column<Integer> column)
Appends all the values in the argument to the bottom of this column and return this column
-
append
public IntColumn append(Column<Integer> 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 IntColumn set(int row, Column<Integer> column, int sourceRow)
Sets the value at row to the value at sourceRow in the given column and return this column
-
set
public Column<Integer> 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
-
appendMissing
public IntColumn appendMissing()
Appends a missing value appropriate to the column- Specified by:
appendMissingin interfaceColumn<Integer>
-
asBytes
public byte[] asBytes(int rowNumber)
Returns the contents of the cell at rowNumber as a byte[].
-
getString
public String getString(int row)
Returns a string representation of the value at the given row.
-
countUnique
public int countUnique()
Returns the count of unique values in this column.- Specified by:
countUniquein interfaceColumn<Integer>- Returns:
- unique values as int
-
getInt
public int getInt(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
intto the argument, with ties rounding to positive infinity.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
intvalue. - 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:
getDoublein interfaceNumberFilters- Specified by:
getDoublein interfaceNumberMapFunctions- Specified by:
getDoublein interfaceNumericColumn<Integer>
-
isMissingValue
public boolean isMissingValue(int value)
-
isMissing
public boolean isMissing(int rowNumber)
Returns true if the value at rowNumber is missing- Specified by:
isMissingin interfaceColumn<Integer>- Specified by:
isMissingin interfaceNumberMapFunctions
-
sortAscending
public void sortAscending()
Sorts my values in ascending order- Specified by:
sortAscendingin interfaceColumn<Integer>
-
sortDescending
public void sortDescending()
Sorts my values in descending order- Specified by:
sortDescendingin interfaceColumn<Integer>
-
appendObj
public IntColumn appendObj(Object obj)
Appends the given value to the bottom of this column and return this column
-
appendCell
public IntColumn 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:
appendCellin interfaceColumn<Integer>
-
appendCell
public IntColumn 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:
appendCellin interfaceColumn<Integer>
-
getUnformattedString
public String getUnformattedString(int row)
Returns a String representation of the value at index r, without any formatting applied- Specified by:
getUnformattedStringin interfaceColumn<Integer>
-
asLongColumn
public LongColumn asLongColumn()
Returns a new LongColumn containing a value for each value in this columnA widening primitive conversion from int to long does not lose any information at all; the numeric value is preserved exactly.
A missing value in the receiver is converted to a missing value in the result
- Specified by:
asLongColumnin interfaceNumericColumn<Integer>
-
asFloatColumn
public FloatColumn asFloatColumn()
Returns a new FloatColumn containing a value for each value in this column, truncating if necessary.A widening primitive conversion from an int 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:
asFloatColumnin interfaceNumericColumn<Integer>
-
isIn
public Selection isIn(int... numbers)
-
isNotIn
public Selection isNotIn(int... numbers)
-
asDoubleColumn
public DoubleColumn asDoubleColumn()
Returns a new DoubleColumn containing a value for each value in this column, truncating if necessary.A widening primitive conversion from an int 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:
asDoubleColumnin interfaceNumericColumn<Integer>
-
asShortColumn
public ShortColumn asShortColumn()
Returns a new ShortColumn 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 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:
asShortColumnin interfaceNumericColumn<Integer>
-
setMissing
public IntColumn setMissing(int r)
Sets the value at index i to the missing-value indicator for this column type, and return this column- Specified by:
setMissingin interfaceColumn<Integer>
-
-