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
{{ message }}
Repository navigation
pandas stats: a nullable Float64/Int64 column loses mean, median and std when its std is pd.NA #1074
numeric_stats (pd_stats_v2.py:147) returns float(ser.mean()), float(ser.std()) and float(ser.median()) from one function. On a nullable column (Float64, Int64) pandas returns pd.NA where numpy dtypes return NaN, float(pd.NA) raises TypeError, and because the three share a function the column loses all three, even when only std is pd.NA.
std is pd.NA when the column holds an infinity, has one non-null value, or is all NA. float64 columns in the same shapes get NaN and keep their mean and median.
Probe script for this issue. Save it as probe_1074.py in a buckaroo checkout and run uv run python probe_1074.py. The output below is from main at e88ace9.
probe_1074.py
"""numeric_stats returns float(ser.mean()), float(ser.std()), float(ser.median()) from one function; on anullable column pandas returns pd.NA where numpy dtypes return NaN, and float(pd.NA) raises."""importlogginglogging.disable(logging.CRITICAL)
importwarningswarnings.filterwarnings('ignore')
importnumpyasnpimportpandasaspdfrombuckaroo.customizations.pd_stats_v2importPD_ANALYSIS_V2frombuckaroo.pluggable_analysis_framework.stat_pipelineimportStatPipelineforlabel, sin [('Float64 with inf', pd.Series([1.0, 2.0, 3.0, np.inf, None], dtype='Float64')),
('Float64 with -inf', pd.Series([1.0, 2.0, -np.inf], dtype='Float64')),
('Float64 one value', pd.Series([1.5, None], dtype='Float64')),
('Int64 one value', pd.Series([1, None], dtype='Int64')),
('Float64 all NA', pd.Series([None, None], dtype='Float64')),
('float64 one value (numpy, for comparison)', pd.Series([1.5, None])),
('float64 with inf (numpy, for comparison)', pd.Series([1.0, 2.0, 3.0, np.inf, None])),
('Float64 spanning +-1e308 (std overflows to inf, no error)', pd.Series([1e308, -1e308, 5.0], dtype='Float64'))]:
sd, errs=StatPipeline(PD_ANALYSIS_V2, unit_test=False).process_df(pd.DataFrame({'a': s}))
print(f"{label:58} raw {s.mean()!s:>8}{s.median()!s:>8}{s.std()!s:>8} | sd {sd['a'].get('mean')!s:>8} "f"{sd['a'].get('median')!s:>8}{sd['a'].get('std')!s:>8} | errors {sorted({e.stat_keyforeinerrs})}")
Activity
paddymul commentedon Oct 7, 2026
Probe script for this issue. Save it as
probe_1074.pyin a buckaroo checkout and runuv run python probe_1074.py. The output below is from main at e88ace9.probe_1074.py
Output at e88ace9