- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the use of series.describe method in Pandas?
The describe() method in the pandas.series is used to generate the statistical description of a series object. This method analyzes the description of both numerical and objective series.
As a result, the describe() method returns a summarized statistics of the series. It varies depending on the type of input series object.
For numerical series, the describe() method analyzes basic statistics like count, mean, std, min, max, and quantile (25%, 50%, and 75%). The 50% quantile is the same as the median.
If the series object has object type data, the describe() method analyzes basic statistics like count, unique, top, and freq.
Example 1
# importing required packages import pandas as pd # creating pandas Series object series = pd.Series([9,2,3,5,8,9,1,4,6]) print(series) # apply describe method print("output",series.describe())
Explanation
Initially, we have created a pandas Series with a python list of integer values. And analyzed the statistics of the series object by using describe() method.
Output
0 9 1 2 2 3 3 5 4 8 5 9 6 1 7 4 8 6 dtype: int64 Output count 9.000000 mean 5.222222 std 2.990726 min 1.000000 25% 3.000000 50% 5.000000 75% 8.000000 max 9.000000 dtype: float64
We calculated the basic statistics of the numerical series object, the results are displayed in the above output block. The count represents the number of elements of the given series object. In the same way, we analyzed the mean, minimum, maximum, standard deviation, and so on.
Example 2
# importing required packages import pandas as pd # creating pandas Series object series = pd.Series(['A', 'B', 'E', 'C', 'A', 'D', 'D', 'E', 'F', 'C', 'B', 'A']) print(series) # apply describe method print("Output: ">"",series.describe())
Explanation
In this following example, we calculated the statistics on an objective type pandas series. For that, we created a series object using a list of strings.
Output
0 A 1 B 2 E 3 C 4 A 5 D 6 D 7 E 8 F 9 C 10 B 11 A dtype: object Output count 12 unique 6 top A freq 3 dtype: object
We got the count of series elements, the total number of unique values, the top (topmost frequent) element, and the frequency of the top value.