Skip to content

[Bug]: DataFrame var(), std(), skew() and kurt() ignore NaN with skipna=False #41873

Done

Description

@anishmehta24

What happened?

With skipna=False, var(), std(), skew() and kurt() on a deferred Series should give NaN when the data has a missing value, like pandas. Beam returns a number instead when the NaN is in a partition together with other values:

import numpy as np
import pandas as pd
import apache_beam as beam
from apache_beam.dataframe.transforms import DataframeTransform

parts = [
    pd.DataFrame({'x': [1.0, np.nan, 3.0]}),
    pd.DataFrame({'x': [4.0, 10.0]}, index=[3, 4]),
]

with beam.Pipeline() as p:
  _ = (
      p | beam.Create(parts)
      | DataframeTransform(
          lambda df: df.x.var(skipna=False),
          proxy=parts[0].iloc[:0],
          yield_elements='pandas')
      | beam.Map(print))
# pandas gives nan, Beam gives 14.883333333333335

std, skew and kurt behave the same, and so do DataFrame.var(skipna=False) and DataFrame.std(skipna=False). Seen on 2.77.0 and on master.

The partition moments in DeferredSeries.var, skew and kurtosis come from pandas std, sum and mean, which skip NaN, while the row count includes it. With skipna=True the NaN rows are dropped first, so only skipna=False is affected.

Issue Priority

Priority: 2 (default / most bugs should be filed as P2)

Issue Components

  • Component: Python SDK

Activity

  1. anishmehta24 commented on Dec 2, 2026

    @anishmehta24
    ContributorAuthor

    .take-issue

  2. added this to the 2.79.0 Release milestone on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions