How to Create a Dataframe Using Describe in Python

To create a dataframe using describe in Python, you can use the describe() function from the pandas library.

The following example shows how to create a dataframe using describe in Python.

Using describe() Function

We can use the describe() function to generate descriptive statistics of a dataframe.

Suppose we have the following dataframe:

# Import pandas library
import pandas as pd

# Create dataframe
df = pd.DataFrame({"A": [89, 74, 85], "B": [25, 62, 63], "C": [12, 23, 22]})

# Use describe() function
df_stat = df.describe()

# Show statistical values
print(df_stat)

Output: 👇️

               A          B          C
count   3.000000   3.000000   3.000000
mean   82.666667  50.000000  19.000000
std     7.767453  21.656408   6.082763
min    74.000000  25.000000  12.000000
25%    79.500000  43.500000  17.000000
50%    85.000000  62.000000  22.000000
75%    87.000000  62.500000  22.500000
max    89.000000  63.000000  23.000000

In this example, we use the describe() function to generate descriptive statistics for the dataframe df.

The output shows the statistical values for the dataframe, including count, mean, standard deviation, minimum, 25th percentile, median, 75th percentile, and maximum.

Conclusion

We can use the describe() function from the pandas library to create a dataframe using describe in Python.