nautechsystems/nautilus_trader · error · ImportError
pandas is required for report generation; install it with…
Error message
pandas is required for report generation; install it with `pip install pandas`
What it means
In apply_stream_conversion_transforms, when use_ts_event_for_ts_init is true the function overwrites ts_init with ts_event values. It first looks up the ts_event column via schema.index_of("ts_event"); arrow's index_of returns an error when the column is absent, and this anyhow error replaces it. Without ts_event the ts_event-for-ts_init substitution cannot be performed.
Solutions
- Verify the source batches contain a ts_event column (batch.schema().column_with_name("ts_event")) before requesting the ts_event-for-ts_init conversion.
- If the data genuinely lacks ts_event, run the conversion without use_ts_event_for_ts_init (keep existing ts_init values instead of substituting).
- Re-export or rewrite the source data with a current writer so both ts_event and ts_init columns exist.
- Check for schema drift: confirm the batches were decoded with the same encoding/writer version that recorded them.
Example fix
// before
let opts = StreamConversionOptions { use_ts_event_for_ts_init: true, .. };
// after: check schema first
assert!(batch.schema().column_with_name("ts_event").is_some(),
"stream data has no ts_event column; disable use_ts_event_for_ts_init"); Defensive patterns
Strategy: validation
Validate before calling
assert!(batch.schema().column_with_name("ts_event").is_some(),
"stream batch lacks ts_event; do not enable use_ts_event_for_ts_init"); Type guard
fn has_ts_event(batch: &RecordBatch) -> bool {
batch.schema().column_with_name("ts_event").is_some()
} Try / catch
match apply_transforms(batches, use_ts_event_for_ts_init) {
Err(e) if e.to_string().contains("ts_event column not found") => {
// fall back to keeping existing ts_init
}
r => r,
} Prevention
- Check schema.column_with_name before enabling the ts_event-for-ts_init option
- Re-record legacy streams with the current writer so both timestamp columns exist
- Keep a schema registry per stream recording version
When it happens
Trigger: Invoking the stream conversion with use_ts_event_for_ts_init = true (e.g. converting old stream data that stored ts_event semantics in ts_init) on batches whose schema has no ts_event column.
Common situations: Converting legacy Feather/stream recordings from older NautilusTrader versions whose data writers did not emit a ts_event column; custom data types that only carry ts_init; schema drift between the recorded stream and the current writer.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- pandas is required for visualization; install it with `pip…
- Chart name cannot be empty
- Failed to concatenate stream batches
- height must be positive, was
- must not be None
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/32200bd03eed25fd.
Report an issue: GitHub.
Appendix: source
Thrown at python/nautilus_trader/analysis/reporter.py:40
from __future__ import annotations
from typing import TYPE_CHECKING
from nautilus_trader.model import OrderFilled
if TYPE_CHECKING:
from typing import Any
import pandas as pd
def _require_pandas() -> None:
try:
import pandas as pd # noqa: F401 (presence check)
except ImportError as e:
raise ImportError(
"pandas is required for report generation; install it with `pip install pandas`",
) from e
def _ns_to_dt(ts: int) -> pd.Timestamp:
import pandas as pd
return pd.Timestamp(ts, tz="UTC")
class ReportProvider:
"""
Provides various portfolio analysis reports.
"""
@staticmethod
def generate_orders_report(orders: list) -> pd.DataFrame:
"""View on GitHub (pinned to 18893faf8b)