dotnet/machinelearning · error · ArgumentException

Must provide at least 1 value column when specifying value…

Error message

Must provide at least 1 value column when specifying value columns manually

What it means

Thrown by DataFrame.Melt when valueColumns is explicitly supplied but resolves to an empty list — i.e. the user opted into specifying value columns manually yet provided none that exist. Raised as ArgumentException (Strings.MissingValueColumns) with paramName 'valueColumns'.

Solutions

  1. Provide at least one existing column name in valueColumns
  2. Omit valueColumns (pass null) to melt all non-ID columns automatically
  3. Validate the provided names exist in DataFrame.Columns before calling

Example fix

// before
df.Melt(ids, new string[0]);
// after
df.Melt(ids, new[] { "Sales", "Cost" }); // or pass null to use all remaining columns
Defensive patterns

Strategy: validation

Validate before calling

if (valueColumns != null && !valueColumns.Any()) valueColumns = null; // fall back to all non-ID columns

Try / catch

try { df.Melt(ids, valueColumns); }
catch (ArgumentException ex) when (ex.ParamName == "valueColumns") { /* retry with null to melt all remaining */ }

Prevention

When it happens

Trigger: Calling df.Melt(ids, Enumerable.Empty<string>()) or df.Melt(ids, new string[0]); also when all provided value column names fail to match DataFrame columns so valueColumnList is empty.

Common situations: User selections that ended up empty in a UI-driven export; typo'd column names filtered out of the list; refactoring removing value columns without updating the call.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at src/Microsoft.Data.Analysis/DataFrame.cs:778

            if (valueColumns is null)
            {
                idColumnSet = [.. idColumnList];
            }

            var valueColumnList = valueColumns?.ToList()
                ?? _columnCollection
                    .Where(c => !idColumnSet.Contains(c.Name))
                    .Select(c => c.Name)
                    .ToList();

            if (idColumnList.Count == 0)
            {
                throw new ArgumentException(Strings.MissingIdColumns, nameof(idColumns));
            }

            if (valueColumns != null && valueColumnList.Count == 0)
            {
                throw new ArgumentException(Strings.MissingValueColumns, nameof(valueColumns));
            }

            if (valueColumns != null && valueColumnList.Any(v => idColumnList.Contains(v)))
            {
                throw new ArgumentException(Strings.DuplicateColumnsInIdAndValueLists, nameof(valueColumns));
            }

            if (valueColumns == null && valueColumnList.Count == 0)
            {
                throw new InvalidOperationException(Strings.NoValueColumnsRemaining);
            }

            if (_columnCollection.IndexOf(variableName) >= 0)
            {
                throw new ArgumentException(string.Format(Strings.VariableNameAlreadyExists, variableName), nameof(variableName));
            }

            if (_columnCollection.IndexOf(valueName) >= 0)

View on GitHub (pinned to 7b76e69cf9)