Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sktime_mcp/data/adapters/pandas_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def load(self) -> pd.DataFrame:
if time_col not in df.columns:
raise ValueError(f"Time column '{time_col}' not found in data")
df = df.set_index(time_col)
elif not isinstance(df.index, (pd.DatetimeIndex, pd.RangeIndex, pd.Index)):
elif not isinstance(df.index, (pd.DatetimeIndex, pd.RangeIndex)):
# Try to detect time column
Comment on lines +54 to 55
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After removing pd.Index from this check, _detect_time_column() will now run when df.index is a pd.PeriodIndex (and other pd.Index subclasses like MultiIndex). Since validate() explicitly treats PeriodIndex as a supported time index, running auto-detection here can unexpectedly overwrite an existing valid time index via df.set_index(time_col). Consider adding pd.PeriodIndex to the tuple (and/or explicitly skipping auto-detection for other already-acceptable index types) so only truly "generic"/non-time-like indexes trigger detection.

Suggested change
elif not isinstance(df.index, (pd.DatetimeIndex, pd.RangeIndex)):
# Try to detect time column
elif not isinstance(df.index, (pd.DatetimeIndex, pd.RangeIndex, pd.PeriodIndex)):
# Try to detect time column only when there is no already-supported time index

Copilot uses AI. Check for mistakes.
time_col = self._detect_time_column(df)
if time_col:
Expand Down
Loading