Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Gets the DataFrame's current storage level.
Returns
StorageLevel
Examples
:::note 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.
:::
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)