@Test public void testToString() { DataFrameInlinePrintWorker w = new DataFrameInlinePrintWorker(new StringBuilder(), 5, 10); assertEquals("{col1:one,column2:1},{col1:two,column2:2},{col1:three,column2:3},{col1:four,column2:4}", w.print(df).toString()); }
public StringBuilder print(DataFrame df) { if (df == null) { out.append("null"); return out; } DataFrameTruncator truncator = DataFrameTruncator.create(df, maxDisplayRows); Index columns = df.getColumnsIndex(); int width = columns.size(); int h = truncator.height(); String[] labels = columns.getLabels(); if (h == 0) { for (int j = 0; j < width; j++) { if (j > 0) { out.append(","); } appendTruncate(labels[j]); out.append(":"); } return out; } boolean comma = false; for (RowProxy p : truncator.head()) { if (comma) { out.append(","); } comma = true; out.append("{"); for (int j = 0; j < width; j++) { if (j > 0) { out.append(","); } appendTruncate(labels[j]); out.append(":"); appendTruncate(String.valueOf(p.get(j))); } out.append("}"); } if (truncator.isTruncated()) { if (comma) { out.append(","); } out.append("..."); for (RowProxy p : truncator.tail()) { out.append(",{"); for (int j = 0; j < width; j++) { if (j > 0) { out.append(","); } appendTruncate(labels[j]); out.append(":"); appendTruncate(String.valueOf(p.get(j))); } out.append("}"); } } return out; }
DataFrameInlinePrintWorker extends BasePrintWorker { public StringBuilder print(DataFrame df) { if (df == null) { out.append("null"); return out; } DataFrameTruncator truncator = DataFrameTruncator.create(df, maxDisplayRows); Index columns = df.getColumnsIndex(); int width = columns.size(); int h = truncator.height(); String[] labels = columns.getLabels(); if (h == 0) { for (int j = 0; j < width; j++) { if (j > 0) { out.append(","); } appendTruncate(labels[j]); out.append(":"); } return out; } boolean comma = false; for (RowProxy p : truncator.head()) { if (comma) { out.append(","); } comma = true; out.append("{"); for (int j = 0; j < width; j++) { if (j > 0) { out.append(","); } appendTruncate(labels[j]); out.append(":"); appendTruncate(String.valueOf(p.get(j))); } out.append("}"); } if (truncator.isTruncated()) { if (comma) { out.append(","); } out.append("..."); for (RowProxy p : truncator.tail()) { out.append(",{"); for (int j = 0; j < width; j++) { if (j > 0) { out.append(","); } appendTruncate(labels[j]); out.append(":"); appendTruncate(String.valueOf(p.get(j))); } out.append("}"); } } return out; } }
DataFrameInlinePrintWorker extends BasePrintWorker { public StringBuilder print(DataFrame df) { if (df == null) { out.append("null"); return out; } DataFrameTruncator truncator = DataFrameTruncator.create(df, maxDisplayRows); Index columns = df.getColumnsIndex(); int width = columns.size(); int h = truncator.height(); String[] labels = columns.getLabels(); if (h == 0) { for (int j = 0; j < width; j++) { if (j > 0) { out.append(","); } appendTruncate(labels[j]); out.append(":"); } return out; } boolean comma = false; for (RowProxy p : truncator.head()) { if (comma) { out.append(","); } comma = true; out.append("{"); for (int j = 0; j < width; j++) { if (j > 0) { out.append(","); } appendTruncate(labels[j]); out.append(":"); appendTruncate(String.valueOf(p.get(j))); } out.append("}"); } if (truncator.isTruncated()) { if (comma) { out.append(","); } out.append("..."); for (RowProxy p : truncator.tail()) { out.append(",{"); for (int j = 0; j < width; j++) { if (j > 0) { out.append(","); } appendTruncate(labels[j]); out.append(":"); appendTruncate(String.valueOf(p.get(j))); } out.append("}"); } } return out; } DataFrameInlinePrintWorker(StringBuilder out, int maxDisplayRows, int maxDisplayColumnWith); }
DataFrameInlinePrintWorker extends BasePrintWorker { public StringBuilder print(DataFrame df) { if (df == null) { out.append("null"); return out; } DataFrameTruncator truncator = DataFrameTruncator.create(df, maxDisplayRows); Index columns = df.getColumnsIndex(); int width = columns.size(); int h = truncator.height(); String[] labels = columns.getLabels(); if (h == 0) { for (int j = 0; j < width; j++) { if (j > 0) { out.append(","); } appendTruncate(labels[j]); out.append(":"); } return out; } boolean comma = false; for (RowProxy p : truncator.head()) { if (comma) { out.append(","); } comma = true; out.append("{"); for (int j = 0; j < width; j++) { if (j > 0) { out.append(","); } appendTruncate(labels[j]); out.append(":"); appendTruncate(String.valueOf(p.get(j))); } out.append("}"); } if (truncator.isTruncated()) { if (comma) { out.append(","); } out.append("..."); for (RowProxy p : truncator.tail()) { out.append(",{"); for (int j = 0; j < width; j++) { if (j > 0) { out.append(","); } appendTruncate(labels[j]); out.append(":"); appendTruncate(String.valueOf(p.get(j))); } out.append("}"); } } return out; } DataFrameInlinePrintWorker(StringBuilder out, int maxDisplayRows, int maxDisplayColumnWith); StringBuilder print(DataFrame df); }
DataFrameInlinePrintWorker extends BasePrintWorker { public StringBuilder print(DataFrame df) { if (df == null) { out.append("null"); return out; } DataFrameTruncator truncator = DataFrameTruncator.create(df, maxDisplayRows); Index columns = df.getColumnsIndex(); int width = columns.size(); int h = truncator.height(); String[] labels = columns.getLabels(); if (h == 0) { for (int j = 0; j < width; j++) { if (j > 0) { out.append(","); } appendTruncate(labels[j]); out.append(":"); } return out; } boolean comma = false; for (RowProxy p : truncator.head()) { if (comma) { out.append(","); } comma = true; out.append("{"); for (int j = 0; j < width; j++) { if (j > 0) { out.append(","); } appendTruncate(labels[j]); out.append(":"); appendTruncate(String.valueOf(p.get(j))); } out.append("}"); } if (truncator.isTruncated()) { if (comma) { out.append(","); } out.append("..."); for (RowProxy p : truncator.tail()) { out.append(",{"); for (int j = 0; j < width; j++) { if (j > 0) { out.append(","); } appendTruncate(labels[j]); out.append(":"); appendTruncate(String.valueOf(p.get(j))); } out.append("}"); } } return out; } DataFrameInlinePrintWorker(StringBuilder out, int maxDisplayRows, int maxDisplayColumnWith); StringBuilder print(DataFrame df);  }