[Bug]: DataFrame mean() and std() fail on datetime and timedelta columns
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
What happened?
mean() and std() on a deferred Series of datetime64 or timedelta64 values fail. pandas returns a Timestamp or a Timedelta:
import pandas as pd
import apache_beam as beam
from apache_beam.dataframe.transforms import DataframeTransform
df = pd.DataFrame({
'wait': pd.to_timedelta([10, 20, 60], unit='s'),
'at': pd.to_datetime(['2024-01-01', '2024-01-02', '2024-01-06']),
})
with beam.Pipeline() as p:
_ = (
p | beam.Create([df])
| DataframeTransform(
lambda df: df.wait.mean(), proxy=df.iloc[:0], yield_elements='pandas')
| beam.Map(print))
# pandas gives Timedelta('0 days 00:00:30'), Beam raises ZeroDivisionError
df['at'].mean() raises TypeError: 'DatetimeArray' with dtype datetime64[ns] does not support reduction 'sum', and std() on either column raises TypeError: unsupported operand type(s) for ** or pow(): 'NaTType' and 'int'. Tz-aware datetimes and DataFrame.mean/std(numeric_only=False) fail the same way. Seen on 2.77.0 and on master.
DeferredSeries.mean divides sum() by count(), which can't work for datetimes and fails on the empty timedelta proxy (Timedelta(0) / 0). std goes through var, which squares the result of pandas std, a Timedelta here. pandas computes both on the values as floats in the unit of the dtype and converts the result back.
Issue Priority
Priority: 2 (default / most bugs should be filed as P2)
Issue Components
- Component: Python SDK
- Ngôn ngữ chính
- Java
- Star
- 8.7k
- Fork
- 4.8k
- Merge trung bình
- 3 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 446
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/beam
-
[Bug]: [Python] BigTableEnrichmentHandler coerces None lookup keys to literal b'None' and formats blank key name on KeyErrorCó thể đã có người làm @shikhabhadoria đã nhận 10 ngày trước. Đang mởio P2 python
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
apache/beam#41346 · 4 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Release notes links wrongCó thể đã có người làm @schizophrenicmaniac đã nhận 24 ngày trước. Đang mởbug P3
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 67/100
apache/beam#41197 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
apache/beam#39624 · 2 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug]: PubsubIO used in batch incorrect batch cutoff sizeCó thể đã có người làm @1fanwang đã nhận 103 ngày trước. Đang mởbug io P3 pinned pubsub
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/beam#28011 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
build P3 sub-task
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 2 ngày
Issue tương tự
-
missing Git commit for 10.5-RC2Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
avaje/avaje-metrics#142 · 1 bình luận ·
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
RamazanKara/nightjar#299 · 4 bình luận ·
-
Support emergency=access_point (POI type and rendering)Có thể đã có người làm @julenepj đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
osmandapp/OsmAnd#27424 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Link not working in the feedback concerning String.format() in exercise 'Tim from Marketing'Có thể đã có người làm @LaibaMunir016 đã nhận 1 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
exercism/java-analyzer#379 · 1 bình luận ·
-
TasksRunnerService.decode() should treat an empty lambdaBody as absentCó thể đã có người làm @gky051224 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
redisson/redisson#7477 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày