Skip to content

Commit de9e468

Browse files
authored
Align columns by 10 or more (in case of longer column names) (dotnet#6673)
1 parent 1dcae10 commit de9e468

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Microsoft.Data.Analysis/DataFrame.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,18 +671,20 @@ public override string ToString()
671671
{
672672
longestColumnName = Math.Max(longestColumnName, Columns[i].Name.Length);
673673
}
674+
675+
int padding = Math.Max(10, longestColumnName + 1);
674676
for (int i = 0; i < Columns.Count; i++)
675677
{
676-
// Left align by 10
677-
sb.Append(string.Format(Columns[i].Name.PadRight(longestColumnName)));
678+
// Left align by 10 or more (in case of longer column names)
679+
sb.Append(string.Format(Columns[i].Name.PadRight(padding)));
678680
}
679681
sb.AppendLine();
680682
long numberOfRows = Math.Min(Rows.Count, 25);
681683
for (int i = 0; i < numberOfRows; i++)
682684
{
683685
foreach (object obj in Rows[i])
684686
{
685-
sb.Append((obj ?? "null").ToString().PadRight(longestColumnName));
687+
sb.Append((obj ?? "null").ToString().PadRight(padding));
686688
}
687689
sb.AppendLine();
688690
}

0 commit comments

Comments
 (0)