Display df.describe() Output In A Dataframe
The .describe() function in Python is really handy for exploratory analysis! Sometimes, you would want to display this as a table on a dashboard, but how? The output is typically printed out as text, not as a dataframe.
Fear not, getting this into a dataframe is fairly painless!
Before we go on, note that using Python requires the Python/R Integration.
Let's say this is the first 10 rows of your SQL output / starting dataframe (the data below is the User IDs and number of gameplays they made for a fictional gaming company)

print(df['gameplay_number'].describe()) gives you the following output

To get this in a table of its own (rather than a printout), use the code below! Note, the key in the dictionary used as an argument for pd.DataFrame is what we want to name the column of summary values in our final output. I chose to name this 'gameplays.'
And there you have it!


1 comment
emmaagro
·2 years ago