BUG: cov buggy when having NaT in column (original) (raw)

Pandas version checks

Reproducible Example

df = DataFrame({ "a": [1, 2, 3], # "b": [pd.Timestamp("1970-01-01 00:00:00.000000001"), pd.Timestamp("1970-01-01 00:00:00.000000002"), pd.NaT], "b": [1, 2, np.nan], "c": [1, 2, 3], }) df.cov()

Issue Description

If I understand this correctly, both calculations should be equivalent. The np.nan case returns

     a    b    c
a  1.0  0.5  1.0
b  0.5  0.5  0.5
c  1.0  0.5  1.0

while the NaT case returns

              a             b             c
a  1.000000e+00 -4.611686e+18  1.000000e+00
b -4.611686e+18  2.835686e+37 -4.611686e+18
c  1.000000e+00 -4.611686e+18  1.000000e+00

Both are equivalent without any missing values

Expected Behavior

Same result for both

Installed Versions

main