dotnet/machinelearning · error · ArgumentException
Strings.MismatchedValueType (formatted with typeof(string))
Error message
Strings.MismatchedValueType (formatted with typeof(string))
What it means
Thrown by ArrowStringDataFrameColumn.FillNullsImplementation when the object passed to FillNulls is not a string. The column stores UTF-8 byte buffers of strings, so only a string replacement value is meaningful; any other runtime type (int, byte[], etc.) triggers this guard, whose message is formatted with typeof(string) to tell the caller the only accepted type.
Source
Thrown at src/Microsoft.Data.Analysis/DataFrameColumns/ArrowStringDataFrameColumn.cs:554
}
ArrowStringDataFrameColumn ret = new ArrowStringDataFrameColumn(Name);
for (long i = 0; i < Length; i++)
{
ret.Append(IsValid(i) ? GetBytes(i) : Encoding.UTF8.GetBytes(value));
}
return ret;
}
protected override DataFrameColumn FillNullsImplementation(object value, bool inPlace)
{
if (value is string valueString)
{
return FillNulls(valueString, inPlace);
}
else
{
throw new ArgumentException(String.Format(Strings.MismatchedValueType, typeof(string)), nameof(value));
}
}
/// <inheritdoc/>
public new ArrowStringDataFrameColumn DropNulls()
{
return (ArrowStringDataFrameColumn)DropNullsImplementation();
}
protected override DataFrameColumn DropNullsImplementation()
{
var ret = new ArrowStringDataFrameColumn(Name);
for (long i = 0; i < Length; i++)
{
if (IsValid(i))
ret.Append(GetBytes(i));
}View on GitHub (pinned to 7b76e69cf9)
Solutions
- Pass a string value to DataFrame.FillNulls, e.g. col.FillNulls("N/A") or the in-place overload FillNulls(value, inPlace: true)
- If the fill value arrives as object from generic code, check `value is string` before calling and convert or reject it upstream
- To fill with a non-string value, first convert the column to a matching primitive column type (e.g. via ConvertTo or ChangeColumnType) and fill there
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at src/Microsoft.Data.Analysis/DataFrameColumns/ArrowStringDataFrameColumn.cs:554 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11).
Data as JSON: /api/errors/de4ac4fbd8d9e8cb.
Report an issue: GitHub.