is there a way to check `isinstance` of a given da...
# datascience
y
is there a way to check
isinstance
of a given dataschema type to detect which schema decoder object to retreive dynamically when dealing with dataframe csv?
n
Hi In dev versions, for example 0.14.0-dev-3829, it's possible to do this:
Copy code
@DataSchema
interface MySchema {
    val a: Int
}

fun main() {
    val targetSchema = DataFrame.emptyOf<MySchema>().compileTimeSchema()
    val df = dataFrameOf("a")(123)
    val res = if (targetSchema.compare(df.schema()).isSuperOrEqual()) {
        df.cast<MySchema>()
    } else {
        null
    }
}
DataFrame<T>.compileTimeSchema
(new function) creates a DataFrameSchema object based on reflective introspection of MySchema interface.
DataFrame<T>.schema
based on runtime data. Is this what do you mean by schema decoder object and retrieving it dynamically?
y
hi @Nikita Klimenko [JB] thanks, yes this is what I was looking for.. is this going to be part of the release at somepoint? also how to test this version, as in how to import this 0.14.0-dev-3829 version library in gradle?
n
Artifacts are published on maven central and gradle plugin portal, so this should work:
Copy code
implementation("org.jetbrains.kotlinx:dataframe:0.14.0-dev-3829")
and
Copy code
plugins {
    id("org.jetbrains.kotlinx.dataframe") version "0.14.0-dev-3829"
}
Yes, we plan to include it in the next release
y
thanks this worked great!
🎉 1