Skip to content

Table Basics

Use emzed.Table when you want typed, expression-based tabular data. Columns such as mz and rt can use emzed.MzType and emzed.RtType so they print with domain-specific formatting.

"""Create and manipulate an emzed table."""

import emzed

peaks = emzed.Table.create_table(
    ["compound", "mz", "rt", "area"],
    [str, emzed.MzType, emzed.RtType, float],
    rows=[
        ["caffeine", 195.08765, 42.0, 2.4e6],
        ["glucose", 181.07066, 60.0, 8.1e5],
        ["arginine", 175.11895, 95.0, 1.2e6],
    ],
)

peaks.add_column("area_million", peaks.area / 1e6, float)

late_peaks = peaks.filter(peaks.rt > 50.0)
summary = late_peaks.extract_columns("compound", "mz", "rt", "area_million")

print(summary)
compound  mz           rt        area_million
str       MzType       RtType    float
--------  -----------  --------  ------------
glucose    181.070660    1.00 m      0.810000
arginine   175.118950    1.58 m      1.200000