dotnet/machinelearning · error · ArgumentException

value

Error message

value

What it means

FillNulls requires a non-null fill value: it throws ArgumentException(nameof(value)) — message is 'value' — when value == null. Since the whole purpose is replacing null strings, a null replacement string is contradictory, so the library rejects it up front.

Source

Thrown at src/Microsoft.Data.Analysis/DataFrameColumns/ArrowStringDataFrameColumn.cs:528

                    else
                    {
                        nullIndices.Add(i);
                    }
                }
                return multimap as Dictionary<TKey, ICollection<long>>;
            }
            else
            {
                throw new NotSupportedException(nameof(TKey));
            }
        }

        /// <inheritdoc/>
        public ArrowStringDataFrameColumn FillNulls(string value, bool inPlace = false)
        {
            if (value == null)
            {
                throw new ArgumentException(nameof(value));
            }
            if (inPlace)
            {
                /* For now throw an exception if inPlace = true. Need to investigate if Apache Arrow
                 * format supports filling nulls for variable length arrays
                 */
                throw new NotSupportedException();
            }

            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)

View on GitHub (pinned to 7b76e69cf9)

Solutions

  1. Pass an actual string, e.g. "" or a sentinel like "N/A".
  2. If the goal is dropping null rows instead, use Filter(IsValid-based boolean column) or DropNulls on the DataFrame.
  3. Check the fill value for null before calling.

Example fix

// before
col.FillNulls(null);
// after
col.FillNulls(string.Empty);
Defensive patterns

Strategy: validation

Validate before calling

if (fillValue == null) fillValue = string.Empty; // or throw with a clear message
col.FillNulls(fillValue);

Try / catch

try { col.FillNulls(value); }
catch (ArgumentException ex) when (ex.ParamName == "value") { col.FillNulls(string.Empty); }

Prevention

When it happens

Trigger: Calling column.FillNulls(null, inPlace) — literal null passed as the fill string.

Common situations: Variable holding the fill value is null because config/parse produced null; developer assumes null means 'remove nulls' rather than fill.

Related errors


AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11). Data as JSON: /api/errors/354843dffc50a474. Report an issue: GitHub.