Skip to content

Commit

Permalink
Align columns by 10 or more (in case of longer column names)
Browse files Browse the repository at this point in the history
  • Loading branch information
asmirnov82 committed May 11, 2023
1 parent 3d705bf commit 9c3e59a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Microsoft.Data.Analysis/DataFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -671,18 +671,20 @@ public override string ToString()
{
longestColumnName = Math.Max(longestColumnName, Columns[i].Name.Length);
}

int padding = Math.Max(10, longestColumnName + 1);
for (int i = 0; i < Columns.Count; i++)
{
// Left align by 10
sb.Append(string.Format(Columns[i].Name.PadRight(longestColumnName)));
// Left align by 10 or more (in case of longer column names)
sb.Append(string.Format(Columns[i].Name.PadRight(padding)));
}
sb.AppendLine();
long numberOfRows = Math.Min(Rows.Count, 25);
for (int i = 0; i < numberOfRows; i++)
{
foreach (object obj in Rows[i])
{
sb.Append((obj ?? "null").ToString().PadRight(longestColumnName));
sb.Append((obj ?? "null").ToString().PadRight(padding));
}
sb.AppendLine();
}
Expand Down

0 comments on commit 9c3e59a

Please sign in to comment.