Skip to content

vstack silently drops the mask on a masked Time mixin column, restoring the masked value #20173

Description

@samaloney

Description

~astropy.table.vstack silently discards masking on a Time mixin column. After stacking, .mask reports False for every row, and the rows that were masked before stacking show their original (pre-mask) underlying value again, as if they had never been masked at all. No error or warning is raised.

Similar / Related issues

Time related
#8816, #16370

vstack / table related
#5375, #3662, #6335

Expected behavior

The masks are kept e.g.

combined:
          time
-----------------------
2024-01-01T01:00:00.000
                    ———
                    ———
2024-01-02T04:00:00.000
combined mask: [False  True  True False]

How to Reproduce

import numpy as np
from astropy.table import QTable, vstack
from astropy.time import Time

t1 = QTable()
t1["time"] = Time(["2024-01-01T01:00:00", "2024-01-01T02:00:00"])
t1["time"][1] = np.ma.masked

t2 = QTable()
t2["time"] = Time(["2024-01-02T03:00:00", "2024-01-02T04:00:00"])
t2["time"][0] = np.ma.masked

print("t1:")
print(t1)
print("t1 mask:", t1["time"].mask)

print("t2:")
print(t2)
print("t2 mask:", t2["time"].mask)

combined = vstack([t1, t2])
print("combined:")
print(combined)
print("combined mask:", combined["time"].mask)

Actual output

t1:
          time
-----------------------
2024-01-01T01:00:00.000
                    ———
t1 mask: [False  True]

t2:
          time
-----------------------
                    ———
2024-01-02T04:00:00.000
t2 mask: [ True False]

combined:
          time
-----------------------
2024-01-01T01:00:00.000
2024-01-01T02:00:00.000
2024-01-02T03:00:00.000
2024-01-02T04:00:00.000
combined mask: [False False False False]

Versions

platform
--------
platform.platform() = 'macOS-26.5.2-arm64-arm-64bit-Mach-O'
platform.version() = 'Darwin Kernel Version 25.5.0: Tue Jun  9 22:28:24 PDT 2026; root:xnu-12377.121.10~1/RELEASE_ARM64_T6020'
platform.python_version() = '3.13.5'

packages
--------
astropy              8.0.1
numpy                2.5.1
scipy                1.18.0
matplotlib           3.11.1
pandas               3.0.5
pyerfa               2.0.1.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions