﻿ Pandas Data Series: Compute the minimum, 25th percentile, median, 75th, and maximum of a given series - w3resource

# Pandas Data Series: Compute the minimum, 25th percentile, median, 75th, and maximum of a given series

## Pandas: Data Series Exercise-18 with Solution

Write a Pandas program to compute the minimum, 25th percentile, median, 75th, and maximum of a given series.

Sample Solution :

Python Code :

``````import pandas as pd
import numpy as np
num_state = np.random.RandomState(100)
num_series = pd.Series(num_state.normal(10, 4, 20))
print("Original Series:")
print(num_series)
result = np.percentile(num_series, q=[0, 25, 50, 75, 100])
print("\nMinimum, 25th percentile, median, 75th, and maximum of a given series:")
print(result)
``````

Sample Output:

```Original Series:
0      3.000938
1     11.370722
2     14.612143
3      8.990256
4     13.925283
5     12.056875
6     10.884719
7      5.719827
8      9.242017
9     11.020006
10     8.167892
11    11.740654
12     7.665620
13    13.267388
14    12.690883
15     9.582355
16     7.874878
17    14.118931
18     8.247458
19     5.526727
dtype: float64

Minimum, 25th percentile, median, 75th, and maximum of a given series:
[ 3.00093811  8.09463867 10.23353705 12.21537733 14.61214321]
```

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?

Test your Python skills with w3resource's quiz

﻿

## Python: Tips of the Day

Returns a list with n elements removed from the beginning

Example:

```def tips_take(itr, n = 1):
return itr[:n]
print(tips_take([1, 2, 3], 5))
print(tips_take([1, 2, 3], 0))
```

Output:

```[1, 2, 3]
[]
```