I am trying to use one cell in databricks to display a dataframe and print some text underneath the display. I can't find anything on it on either the Databricks forum or here. It's a devilishly simple question so apologies if it is obvious.
myDF is a a pyspark.sql.dataframe
What I'm doing is:
myString = 'aasdf45'
print(myString)
display(myDF)
The output of the cell displays the DF, but the text isn't printed.
If I do this the other way around, printing the string after the display the result is still the same, showing the dataframe but no printed string:
myString = 'aasdf45'
display(myDF)
print(myString)
It seems like the behaviour is to display the DF over anything else. Is there a way I can show both? It's fine if not but it would be great to know.
Many thanks,
Unfortunately, as things stand with Databricks, you cannot combine a table display with other content. You'll have to put the other content in a separate cell before/after the cell output.
The only alternative for single cell output is quite complicated:
df.collect()
.TABLE
from your data.displayHTML()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With