dotnet/machinelearning · error · ArgumentOutOfRangeException
Column ' ' not found (Parameter 'name')
Error message
Column '{name}' not found (Parameter 'name') What it means
DataViewSchema's string indexer throws ArgumentOutOfRangeException('name') with 'Column not found' when the requested name exists in neither the visible nor hidden columns of the schema. This is the standard signal that a column name is misspelled or absent at this pipeline stage.
Solutions
- Print the schema (loop schema and log column names) to see the actual available names and fix the spelling/casing
- Guard with GetColumnOrNull before indexing
- Reorder pipeline stages so the column exists (apply the producing transform) before accessing it by name
Example fix
// before
var col = schema["Label"];
// after
if (!schema.GetColumnOrNull("Label", out var col))
throw new ArgumentException($"Column 'Label' not found. Available: {string.Join(",", schema.Select(c => c.Name))}"); Defensive patterns
Strategy: type-guard
Validate before calling
bool exists = schema.GetColumnOrNull(name, out var col);
Type guard
static bool TryGetColumn(DataViewSchema schema, string name, out DataViewSchema.Column col)
=> schema.GetColumnOrNull(name, out col); Try / catch
try { var col = schema["Expected"]; }
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "name")
{ log.Error($"Column not found. Available: {string.Join(',', schema.Select(c => c.Name))}", ex); } Prevention
- Use GetColumnOrNull instead of the throwing indexer when a column may be absent
- Log the full schema (column names) after each pipeline stage during development
- Centralize column-name constants to avoid typos and casing mismatches
- Remember column names are case-sensitive in ML.NET DataViewSchema
When it happens
Trigger: Accessing schema["ColumnName"] where the column was never created, was renamed by a transform, or was consumed/dropped earlier in the pipeline; case-sensitive name mismatch.
Common situations: Typos or casing differences in column names; accessing a feature column before a featurizing transform ran; column dropped by ColumnSelecting/CustomMapping; switching to a different dataset whose schema differs.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Value cannot be null. (Parameter 'name')
- Bad data kind in ColumnTypeExtensions.NumberTypeFromKind
- Bad type in ColumnTypeExtensions.NumberTypeFromType
- column
- Column ' ' does not exist
AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11).
Data as JSON: /api/errors/1845c3e72bab8148.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.ML.DataView/DataViewSchema.cs:40
private readonly Dictionary<string, int> _nameMap;
/// <summary>
/// Number of columns in the schema.
/// </summary>
public int Count => _columns.Length;
/// <summary>
/// Get the column by name. Throws an exception if such column does not exist.
/// Note that if multiple columns exist with the same name, the one with the biggest index is returned.
/// The other columns are considered 'hidden', and only accessible by their index.
/// </summary>
public Column this[string name]
{
get
{
if (string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name));
if (!_nameMap.TryGetValue(name, out int col))
throw new ArgumentOutOfRangeException(nameof(name), $"Column '{name}' not found");
return _columns[col];
}
}
/// <summary>
/// Get the column by index.
/// </summary>
public Column this[int columnIndex]
{
get
{
if (!(0 <= columnIndex && columnIndex < _columns.Length))
throw new ArgumentOutOfRangeException(nameof(columnIndex));
return _columns[columnIndex];
}
}
/// <summary>View on GitHub (pinned to 7b76e69cf9)