Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python List Statistics not correct

I try to calculate some stats for a list. But somehow these are not correct:
Code:
import pandas as pd

import statistics


list_runs_stats=[4.149432, 3.133142, 3.182976, 2.620959, 3.200038, 2.66668, 2.604444, 2.683382, 3.249564, 3.149947]

list_stats=pd.Series(list_runs_stats).describe()

print (list_stats.mean())
print (list_stats.min())
print (list_stats.max())
print (list_stats.median())
print (list_stats.count())

Result:

3.6617099664905832
0.467574831924664
10.0
3.10280045
8

I think min, max and count is quite obvious that it is not correct.
Excel gives me mean: 3.0640564 and median:3,1415445

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What I am doing wrong?

>Solution :

By assigning the output of describe() to list_stats, you are calculating the min and max of the output of describe function

Can you try this this instead?

import pandas as pd
list_runs_stats=[4.149432, 3.133142, 3.182976, 2.620959, 3.200038, 2.66668, 2.604444, 2.683382, 3.249564, 3.149947]
df = pd.Series(list_runs_stats)
df.describe()
#Output
count    10.000000
mean      3.064056
std       0.467575
min       2.604444
25%       2.670856
50%       3.141545
75%       3.195773
max       4.149432
dtype: float64
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading