Skip to content

Commit

Permalink
code sample for pandas-dev#42878
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjayhawkins committed Aug 4, 2021
1 parent 2555124 commit 59b75e6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions bisect/42878.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# BUG: [float32 precision] pandas float32 mean is inconsistent with numpy #42878

import numpy as np

import pandas as pd

print(pd.__version__)

a = pd.Series(np.random.normal(scale=0.1, size=(1_000_000,)).astype(np.float32)).pow(2)

result = np.mean(a)
print(result, type(result))

expected = np.mean(a.values)
assert isinstance(result, np.float32)
assert isinstance(expected, np.float32)
assert result == expected

0 comments on commit 59b75e6

Please sign in to comment.