{"record":{"id":"1845c3e72bab8148","repo":"dotnet/machinelearning","slug":"column-name-not-found-parameter-name","errorCode":null,"errorMessage":"Column '{name}' not found (Parameter 'name')","messagePattern":"Column '(.+?)' not found \\(Parameter 'name'\\)","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.DataView/DataViewSchema.cs","lineNumber":40,"sourceCode":"        private readonly Dictionary<string, int> _nameMap;\n\n        /// <summary>\n        /// Number of columns in the schema.\n        /// </summary>\n        public int Count => _columns.Length;\n\n        /// <summary>\n        /// Get the column by name. Throws an exception if such column does not exist.\n        /// Note that if multiple columns exist with the same name, the one with the biggest index is returned.\n        /// The other columns are considered 'hidden', and only accessible by their index.\n        /// </summary>\n        public Column this[string name]\n        {\n            get\n            {\n                if (string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name));\n                if (!_nameMap.TryGetValue(name, out int col))\n                    throw new ArgumentOutOfRangeException(nameof(name), $\"Column '{name}' not found\");\n                return _columns[col];\n            }\n        }\n\n        /// <summary>\n        /// Get the column by index.\n        /// </summary>\n        public Column this[int columnIndex]\n        {\n            get\n            {\n                if (!(0 <= columnIndex && columnIndex < _columns.Length))\n                    throw new ArgumentOutOfRangeException(nameof(columnIndex));\n                return _columns[columnIndex];\n            }\n        }\n\n        /// <summary>","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.DataView/DataViewSchema.cs#L22-L58","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nvar col = schema[\"Label\"];\n// after\nif (!schema.GetColumnOrNull(\"Label\", out var col))\n    throw new ArgumentException($\"Column 'Label' not found. Available: {string.Join(\",\", schema.Select(c => c.Name))}\");","handlingStrategy":"type-guard","validationCode":"bool exists = schema.GetColumnOrNull(name, out var col);","typeGuard":"static bool TryGetColumn(DataViewSchema schema, string name, out DataViewSchema.Column col)\n    => schema.GetColumnOrNull(name, out col);","tryCatchPattern":"try { var col = schema[\"Expected\"]; }\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"name\")\n{ log.Error($\"Column not found. Available: {string.Join(',', schema.Select(c => c.Name))}\", ex); }","preventionTips":["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"],"tags":["schema","column-not-found","dataview"],"backgroundTag":"entity-not-found","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}