storageLevel
Gets the DataFrame's current storage level.
Returns
StorageLevel
Examples
Serverless compatibility
Databricks recommends moving away from df.cache() and df.persist() as they are not compatible with Databricks serverless compute architecture. Materialize intermediate results to Delta tables instead.
Python
df1 = spark.range(10)
df1.storageLevel
# StorageLevel(False, False, False, False, 1)
df1.cache().storageLevel
# StorageLevel(True, True, False, True, 1)
df2 = spark.range(5)
df2.persist(StorageLevel.DISK_ONLY_2).storageLevel
# StorageLevel(True, False, False, False, 2)