Skip to content

Instantly share code, notes, and snippets.

@shubham0204
Created March 14, 2021 07:43
Show Gist options
  • Save shubham0204/45ff7ae1a6e66d9eae8bf9d01aca8cf5 to your computer and use it in GitHub Desktop.
Save shubham0204/45ff7ae1a6e66d9eae8bf9d01aca8cf5 to your computer and use it in GitHub Desktop.
// Return samples ( in form of DataFrame object ) given their indices.
fun getEntries( indices : IntArray ) : DataFrame {
val dataFrame = DataFrame()
data.map { column ->
// `column` represent a Map -> ( String , ArrayList<String> )
// column.key -> Name of the column as in the training datasets.
// column.value -> ArrayList<String> containing the column's data.
val columnData = ArrayList<String>()
val values = column.value
// Add the feature values corresponding to each index in `indices`.
for ( index in indices ) {
columnData.add( values[ index ] )
}
println( "column data ${columnData.toTypedArray().contentToString()} , ${indices.size}")
// Append the column to the data frame.
dataFrame.addColumn( columnData , column.key )
}
return dataFrame
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment