`DataScan` and `col_summary_tbl()` don't treat NaN as missing on Polars, PyArrow and Ibis tables
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start by tracing DataScan's column profiling and the statistics used by col_summary_tbl(); compare how the pandas, Polars, PyArrow, and Ibis backends identify missing float values. Use the reproduction in the issue to check n_missing, the other statistics, and sample values. Done means all backends report the pandas results, with NaN counted as missing and excluded from other statistics.
由索引模型根据 Issue 内容生成。
描述
When a float column holds NaN, DataScan (and so col_summary_tbl()) gives different results depending on the backend. On pandas, NaN is counted in n_missing and left out of the other statistics, as the docs describe for missing values. On Polars, PyArrow and Ibis tables, NaN isn't counted as missing and stays in the statistics: the mean, SD and P95 become NaN, the median and Q3 shift on Polars (it sorts NaN above every number), n_unique counts NaN and null as two separate values, and nan shows up in the sample values.
Minimal reproduction:
import polars as pl
import pointblank as pb
df = pl.DataFrame({"x": [1.0, 2.0, 3.0, 4.0, float("nan"), None]})
for tbl in (df, df.to_pandas(), df.to_arrow()):
(prof,) = pb.DataScan(tbl).profile.column_profiles
stats = {s.name: s.val for s in prof.statistics}
print({k: stats[k] for k in ("n_missing", "n_unique", "mean", "std", "median", "q_3", "p95")}, prof.sample_data)
Output (tidied):
polars {'n_missing': 1, 'n_unique': 6, 'mean': nan, 'std': nan, 'median': 3.0, 'q_3': 4.0, 'p95': nan} ['1.0', '2.0', '3.0', '4.0', 'nan']
pandas {'n_missing': 2, 'n_unique': 5, 'mean': 2.5, 'std': 1.291, 'median': 2.5, 'q_3': 3.25, 'p95': 3.85} ['1.0', '2.0', '3.0', '4.0']
pyarrow {'n_missing': 1, 'n_unique': 6, 'mean': nan, 'std': nan, 'median': 2.5, 'q_3': 3.25, 'p95': 3.85} ['1.0', '2.0', '3.0', '4.0', 'nan']
An Ibis table on DuckDB (ibis.memtable(df.to_arrow())) gives the same result as PyArrow, and a Polars LazyFrame the same as Polars.
Expected: the same profile on every backend, the one pandas gives. NaN counts as missing (n_missing is 2) and is left out of the other statistics, as the to_dict() docs say for a missing value ("The missing reading is counted in n_missing and left out of the other statistics"). This would also match how NaN is handled elsewhere in Pointblank, for example in missing_vals_tbl(), col_vals_null() and schema inference.
Actual: on Polars, PyArrow and Ibis tables, NaN is counted as a value. The NA column of col_summary_tbl() misses it, and Mean and SD are NaN (P95 too on Polars).
Environment: pointblank main (d82e523), Python 3.12.13, Polars 2.1.0, pandas 3.1.0, PyArrow 26.0.0, Ibis 12.0.0, DuckDB 1.5.6, Narwhals 2.28.0, macOS.
- 主要语言
- Python
- 星标
- 506
- 派生
- 42
- 平均合并
- 5 小时 46 分钟
- 30 天内合并 PR
- 89
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
posit-dev/pointblank 的其他 Issue
-
Type: ⁇ Question
难度 5/5 一周以上 新手友好度 15/100
posit-dev/pointblank#567 · 3 条评论 ·
维护者通常 1 天内回复
-
An equivalent of "multi-agent reports"可能重新可做 @rich-iannone 于 456 天前认领,目前没有进行中的 PR。 未关闭Difficulty: [3] Advanced Effort: [3] High Priority: [2] Medium Type: ★ Enhancement
posit-dev/pointblank#254 · 1 条评论 · 1 个 reaction · 已指派 1 人 ·
维护者通常 1 天内回复
-
Type: ★ Enhancement
难度 4/5 3-5 天 新手友好度 35/100
posit-dev/pointblank#169 · 1 个 reaction ·
维护者通常 1 天内回复
-
Type: ★ Enhancement
难度 5/5 一周以上 新手友好度 30/100
posit-dev/pointblank#92 ·
维护者通常 1 天内回复
-
Type: ★ Enhancement
难度 5/5 一周以上 新手友好度 25/100
posit-dev/pointblank#91 ·
维护者通常 1 天内回复
查看 posit-dev/pointblank 的全部 Issue
相似的 Issue
-
accepted
难度 2/5 1-3 小时 新手友好度 68/100
future-agi/future-agi#6392 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
memmapped_arange ignores the start value and drops the last point above the memmap threshold可能已有人在做 @prathameshfuke 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
StingraySoftware/HENDRICS#213 ·
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
Bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复