You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the above example, standard deviation is calculated twice, in the first case, np.std function directly passed to aggfunc, on the other hand in the second case, a lambda function is passed to aggfunc which uses the same np.std function to calculate standard deviation. The results in these cases must equal.
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
`
import numpy as np
import pandas as pd
df = pd.DataFrame({'A': ['a', 'a'], 'X': [2.8597, 2.8503]})
pivot = pd.pivot_table(df, index='A', values='X', aggfunc=(np.mean, np.std))
my_std = np.std(df.X) # 0.0047000000000001485
pivot_std = pivot.loc['a', 'std'] # 0.006646803743153757
`
Problem description
pivot_table calculates incorrect standard deviation when np.std passed to aggfunc.
Expected Output
Numpy calculates the correct std in the given example.
The text was updated successfully, but these errors were encountered: