I am trying to calulate standard deviation for numbers from 1 to 7
I get different results for numpy and for pandas. I am sure that the result should be 2:
>>> df = pd.DataFrame({'vals': [1, 2, 3, 4, 5, 6, 7]})
>>> df["vals"].std()
2.160246899469287
>>> df["vals"].mean()
4.0
>>>np.std([1, 2, 3, 4, 5, 6, 7])
2.0
>>>np.mean([1, 2, 3, 4, 5, 6, 7])
4.0
What is wrong here?
np.std(df['vals'], ddof=1)you get the same answer.df["vals"].mean()gave 2.