Package smile.data.vector
Class StringVector
- All Implemented Interfaces:
Serializable
,ValueVector
A string vector.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionStringVector
(String name, String[] vector) Constructor.StringVector
(StructField field, String[] vector) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturns a DoubleStream consisting of the elements of this vector, converted to double.factorize
(CategoricalMeasure scale) Converts strings to discrete measured values.Returns a new vector with selected entries.boolean
getBoolean
(int i) Returns the boolean value at position i.byte
getByte
(int i) Returns the byte value at position i.char
getChar
(int i) Returns the character value at position i.double
getDouble
(int i) Returns the double value at position i.float
getFloat
(int i) Returns the float value at position i.int
getInt
(int i) Returns the integer value at position i.long
getLong
(int i) Returns the long value at position i.short
getShort
(int i) Returns the short value at position i.Returns an IntStream consisting of the elements of this vector, converted to integer.Returns a LongStream consisting of the elements of this vector, converted to long.nominal()
Returns a nominal scale of measure based on distinct values in the vector.Returns the vector with the new name.Methods inherited from class smile.data.vector.ObjectVector
distinct, get, getNullCount, isNullable, isNullAt, of, of, of, of, of, of, of, of, set, size, stream
Methods inherited from class smile.data.vector.AbstractVector
field, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface smile.data.vector.ValueVector
anyNull, apply, apply, dtype, eq, ge, get, getScale, getString, gt, isin, isNull, le, lt, measure, name, ne, slice, slice, toDoubleArray, toIntArray, toLongArray, toStringArray, toStringArray, update
-
Constructor Details
-
StringVector
Constructor.- Parameters:
name
- the name of vector.vector
- the elements of vector.
-
StringVector
Constructor.- Parameters:
field
- the struct field of vector.vector
- the elements of vector.
-
-
Method Details
-
nominal
Returns a nominal scale of measure based on distinct values in the vector.- Returns:
- the nominal scale.
-
factorize
Converts strings to discrete measured values. Depending on how many levels in the nominal scale, the type of returned vector may be byte, short or integer. The missing values/nulls will be converted to -1.- Parameters:
scale
- the categorical measure.- Returns:
- the factorized vector.
-
get
Description copied from interface:ValueVector
Returns a new vector with selected entries.- Specified by:
get
in interfaceValueVector
- Overrides:
get
in classObjectVector<String>
- Parameters:
index
- the index of selected entries.- Returns:
- the new vector of selected entries.
-
withName
Description copied from interface:ValueVector
Returns the vector with the new name.- Specified by:
withName
in interfaceValueVector
- Overrides:
withName
in classObjectVector<String>
- Parameters:
name
- the new name.- Returns:
- the vector with the new name.
-
intStream
Description copied from interface:ValueVector
Returns an IntStream consisting of the elements of this vector, converted to integer.- Returns:
- an IntStream consisting of the elements of this vector.
-
longStream
Description copied from interface:ValueVector
Returns a LongStream consisting of the elements of this vector, converted to long.- Returns:
- a LongStream consisting of the elements of this vector.
-
doubleStream
Description copied from interface:ValueVector
Returns a DoubleStream consisting of the elements of this vector, converted to double.- Returns:
- a DoubleStream consisting of the elements of this vector.
-
getBoolean
public boolean getBoolean(int i) Description copied from interface:ValueVector
Returns the boolean value at position i.- Specified by:
getBoolean
in interfaceValueVector
- Overrides:
getBoolean
in classObjectVector<String>
- Parameters:
i
- the index.- Returns:
- the value.
-
getChar
public char getChar(int i) Description copied from interface:ValueVector
Returns the character value at position i.- Specified by:
getChar
in interfaceValueVector
- Overrides:
getChar
in classObjectVector<String>
- Parameters:
i
- the index.- Returns:
- the value.
-
getByte
public byte getByte(int i) Description copied from interface:ValueVector
Returns the byte value at position i.- Specified by:
getByte
in interfaceValueVector
- Overrides:
getByte
in classObjectVector<String>
- Parameters:
i
- the index.- Returns:
- the value.
-
getShort
public short getShort(int i) Description copied from interface:ValueVector
Returns the short value at position i.- Specified by:
getShort
in interfaceValueVector
- Overrides:
getShort
in classObjectVector<String>
- Parameters:
i
- the index.- Returns:
- the value.
-
getInt
public int getInt(int i) Description copied from interface:ValueVector
Returns the integer value at position i.- Specified by:
getInt
in interfaceValueVector
- Overrides:
getInt
in classObjectVector<String>
- Parameters:
i
- the index.- Returns:
- the value.
-
getLong
public long getLong(int i) Description copied from interface:ValueVector
Returns the long value at position i.- Specified by:
getLong
in interfaceValueVector
- Overrides:
getLong
in classObjectVector<String>
- Parameters:
i
- the index.- Returns:
- the value.
-
getFloat
public float getFloat(int i) Description copied from interface:ValueVector
Returns the float value at position i.- Specified by:
getFloat
in interfaceValueVector
- Overrides:
getFloat
in classObjectVector<String>
- Parameters:
i
- the index.- Returns:
- the value.
-
getDouble
public double getDouble(int i) Description copied from interface:ValueVector
Returns the double value at position i.- Specified by:
getDouble
in interfaceValueVector
- Overrides:
getDouble
in classObjectVector<String>
- Parameters:
i
- the index.- Returns:
- the value.
-