{"record":{"id":"5216bb3fb958ea21","repo":"dotnet/machinelearning","slug":"string-format-strings-mismatchedvaluetype-strings","errorCode":null,"errorMessage":"String.Format(Strings.MismatchedValueType, Strings.NumericColumnType)","messagePattern":"String\\.Format\\(Strings\\.MismatchedValueType, Strings\\.NumericColumnType\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs","lineNumber":479,"sourceCode":"        {\n            if (boolColumn.Length > Length)\n                throw new ArgumentException(Strings.MapIndicesExceedsColumnLength, nameof(boolColumn));\n            PrimitiveDataFrameColumn<T> ret = CreateNewColumn(Name);\n\n            for (long i = 0; i < boolColumn.Length; i++)\n            {\n                bool? value = boolColumn[i];\n                if (value.HasValue && value.Value == true)\n                    ret.Append(this[i]);\n            }\n            return ret;\n        }\n\n        private PrimitiveDataFrameColumn<T> CloneImplementation<U>(PrimitiveDataFrameColumn<U> mapIndices, bool invertMapIndices = false)\n            where U : unmanaged\n        {\n            if (!mapIndices.IsNumericColumn())\n                throw new ArgumentException(String.Format(Strings.MismatchedValueType, Strings.NumericColumnType), nameof(mapIndices));\n\n            PrimitiveColumnContainer<T> retContainer;\n            if (mapIndices.DataType == typeof(long))\n            {\n                retContainer = _columnContainer.Clone(mapIndices._columnContainer, typeof(long), invertMapIndices);\n            }\n            else if (mapIndices.DataType == typeof(int))\n            {\n                retContainer = _columnContainer.Clone(mapIndices._columnContainer, typeof(int), invertMapIndices);\n            }\n            else\n                throw new NotImplementedException();\n\n            PrimitiveDataFrameColumn<T> ret = CreateNewColumn(Name, retContainer);\n            return ret;\n        }\n\n        public PrimitiveDataFrameColumn<T> Clone(PrimitiveDataFrameColumn<long> mapIndices, bool invertMapIndices = false)","sourceCodeStart":461,"sourceCodeEnd":497,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs#L461-L497","documentation":"Clone with a generic unmanaged mapIndices column requires the indices to be numeric (int/long-style select/reorder map). Non-numeric unmanaged columns (e.g. bool already handled separately, or an unexpected type) make IsNumericColumn() false and throw ArgumentException naming the mapIndices parameter.","triggerScenarios":"Calling the private CloneImplementation<U> path (via Clone) with a non-numeric PrimitiveDataFrameColumn<U> that isn't bool, so the generic numeric-index overload receives a non-numeric column.","commonSituations":"Custom unmanaged struct types or char columns passed as map indices through generic code paths.","solutions":["Pass a long or int PrimitiveDataFrameColumn as mapIndices","Convert custom unmanaged columns to long indices before cloning","Use the bool-column overload when the intent is a row filter mask"],"exampleFix":"// before\ncol.Clone(charIndices); // non-numeric map\n// after\nvar longIdx = new PrimitiveDataFrameColumn<long>(\"idx\");\nfor (long i = 0; i < charIndices.Length; i++) longIdx.Append(charIndices[i]);\ncol.Clone(longIdx);","handlingStrategy":"type-guard","validationCode":"if (!mapIndices.IsNumericColumn()) throw new ArgumentException(\"mapIndices must be a numeric column\");","typeGuard":"bool isNumericMap(DataFrameColumn c) => c.IsNumericColumn();","tryCatchPattern":"try { var clone = column.Clone(mapIndices); } catch (ArgumentException) { /* convert to long indices */ }","preventionTips":["Use long/int PrimitiveDataFrameColumn for index maps","Check IsNumericColumn before generic clone calls","Use bool columns only for mask filtering"],"tags":["type-mismatch","clone","numeric"],"backgroundTag":"type-mismatch","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"}