Package smile.data.vector
Interface StringVector
- All Superinterfaces:
BaseVector<String,
,String, Stream<String>> Serializable
,Vector<String>
An immutable string vector.
-
Method Summary
Modifier and TypeMethodDescriptionfactorize
(CategoricalMeasure scale) Converts strings to discrete measured values.get
(int... index) Returns a new vector with selected entries.default boolean
getBoolean
(int i) Returns the boolean value at position i.default byte
getByte
(int i) Returns the byte value at position i.default char
getChar
(int i) Returns the character value at position i.default double
getDouble
(int i) Returns the double value at position i.default float
getFloat
(int i) Returns the float value at position i.default int
getInt
(int i) Returns the integer value at position i.default long
getLong
(int i) Returns the long value at position i.default short
getShort
(int i) Returns the short value at position i.nominal()
Returns a nominal scale of measure based on distinct values in the vector.static StringVector
Creates a named string vector.static StringVector
of
(StructField field, String... vector) Creates a named string vector.Returns a vector of LocalDate.toDate
(DateTimeFormatter format) Returns a vector of LocalDate.default Vector
<LocalDateTime> toDateTime
(String pattern) Returns a vector of LocalDateTime.toDateTime
(DateTimeFormatter format) Returns a vector of LocalDateTime.default String
toString
(int n) Returns the string representation of vector.Returns a vector of LocalTime.toTime
(DateTimeFormatter format) Returns a vector of LocalDate.Methods inherited from interface smile.data.vector.BaseVector
apply, apply, array, field, get, measure, name, size, stream, toDoubleArray, toDoubleArray, toIntArray, toIntArray, toStringArray, toStringArray, type
-
Method Details
-
get
Description copied from interface:BaseVector
Returns a new vector with selected entries. -
getBoolean
default boolean getBoolean(int i) Description copied from interface:BaseVector
Returns the boolean value at position i.- Specified by:
getBoolean
in interfaceBaseVector<String,
String, Stream<String>> - Specified by:
getBoolean
in interfaceVector<String>
- Parameters:
i
- the index.- Returns:
- the value.
-
getChar
default char getChar(int i) Description copied from interface:BaseVector
Returns the character value at position i. -
getByte
default byte getByte(int i) Description copied from interface:BaseVector
Returns the byte value at position i. -
getShort
default short getShort(int i) Description copied from interface:BaseVector
Returns the short value at position i. -
getInt
default int getInt(int i) Description copied from interface:BaseVector
Returns the integer value at position i. -
getLong
default long getLong(int i) Description copied from interface:BaseVector
Returns the long value at position i. -
getFloat
default float getFloat(int i) Description copied from interface:BaseVector
Returns the float value at position i. -
getDouble
default double getDouble(int i) Description copied from interface:BaseVector
Returns the double value at position i. -
toDate
Returns a vector of LocalDate. This method assumes that this is a string vector and uses the given date format pattern to parse strings.- Parameters:
pattern
- the datetime formatter pattern.- Returns:
- the date vector.
-
toDate
Returns a vector of LocalDate. This method assumes that this is a string vector and uses the given date format pattern to parse strings.- Parameters:
format
- the datetime formatter.- Returns:
- the date vector.
-
toTime
Returns a vector of LocalTime. This method assumes that this is a string vector and uses the given time format pattern to parse strings.- Parameters:
pattern
- the datetime formatter pattern.- Returns:
- the time vector.
-
toTime
Returns a vector of LocalDate. This method assumes that this is a string vector and uses the given time format pattern to parse strings.- Parameters:
format
- the datetime formatter.- Returns:
- the time vector.
-
toDateTime
Returns a vector of LocalDateTime. This method assumes that this is a string vector and uses the given date time format pattern to parse strings.- Parameters:
pattern
- the datetime formatter pattern.- Returns:
- the datetime vector.
-
toDateTime
Returns a vector of LocalDateTime. This method assumes that this is a string vector and uses the given date time format pattern to parse strings.- Parameters:
format
- the datetime formatter.- Returns:
- the datetime vector.
-
nominal
NominalScale 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.
-
toString
Returns the string representation of vector. -
of
Creates a named string vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a named string vector.- Parameters:
field
- the struct field of vector.vector
- the data of vector.- Returns:
- the vector.
-