Мой код выглядит так:
Код: Выделить всё
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "polars",
# "plotly-express",
# ]
# ///
import argparse
import polars as pl
import plotly.express as px
parser = argparse.ArgumentParser(
description="Make a Grantt chart.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument("data_csv", help="path to the spill log CSV file")
args = parser.parse_args()
df = pl.read_csv(args.data_csv).select(
Task="event_description",
Start="start_time",
Finish="stop_time",
Resource="sequencer_name",
)
print(df)
"""
shape: (132, 4)
┌──────────────────────┬────────────┬────────────┬──────────┐
│ Task ┆ Start ┆ Finish ┆ Resource │
│ --- ┆ --- ┆ --- ┆ --- │
│ str ┆ f64 ┆ f64 ┆ str │
╞══════════════════════╪════════════╪════════════╪══════════╡
│ Waiting for CT Stick ┆ 13.521872 ┆ 13.532996 ┆ cat │
│ Pretrigger Received ┆ 80.610743 ┆ 80.610749 ┆ cat │
│ Accumulation ┆ 86.732821 ┆ 186.733757 ┆ pos │
│ Load Electrons ┆ 120.611088 ┆ 138.840772 ┆ cat │
│ CRW1S1 ┆ 138.957786 ┆ 144.360157 ┆ cat │
│ … ┆ … ┆ … ┆ … │
│ Right dump top ┆ 804.286397 ┆ 804.388398 ┆ atm_botg │
│ left dump bot ┆ 804.390398 ┆ 804.492399 ┆ atm_botg │
│ Tdiag dump ┆ 804.506432 ┆ 804.53185 ┆ atm_botg │
│ Fast Clear ┆ 809.570261 ┆ 809.595263 ┆ atm_botg │
│ Fast Clear Strong ┆ 809.597263 ┆ 809.622264 ┆ atm_botg │
└──────────────────────┴────────────┴────────────┴──────────┘
"""
fig = px.timeline(df, x_start="Start", x_end="Finish", y="Resource", color="Resource")
fig.show()

Я также пробовал использовать панд вместо поляров, но результат тот же. Я думаю, проблема в том, что мое «свидание» на самом деле составляет всего лишь некоторое время в секундах. Могу ли я получить несколько советов, как с этим справиться?
Подробнее здесь: https://stackoverflow.com/questions/790 ... -time-axis