Open
Description
This issue is related to #412.
Right now, when an empty DataFrame is printed, it just show an empty frame with no information. When #412 gets implemented, it could print some useful information such as columns names.
Also, currently we get an error if we try to print the ctypes
of an empty Dataframe. This should print the ctypes
even if the DataFrame is empty when the types are defined, or an empty Series when types are not defined (see examples below).
If you think this could be an useful addition, I can try to implement it myself after #412 gets added.
Examples:
var data = {
worker: ["david", "david", "john", "alice", "john", "david"],
day: ["monday", "tuesday", "wednesday", "thursday", "friday", "friday"],
hours: [5, 6, 2, 8, 4, 3],
};
var df = new dfd.DataFrame(data);
var df_filt = df.loc({ rows: df["day"].eq("saturday") });
var edf = new dfd.DataFrame([], { columns: ["hours", "worker", "day"]});
df.print();
// ╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗
// ║ │ worker │ day │ hours ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 0 │ david │ monday │ 5 ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 1 │ david │ tuesday │ 6 ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 2 │ john │ wednesday │ 2 ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 3 │ alice │ thursday │ 8 ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 4 │ john │ friday │ 4 ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 5 │ david │ friday │ 3 ║
// ╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝
// - Printing as expected
df_filt.print();
// ╔════════════╗
// ║ ║
// ╚════════════╝
// - I would expect something like:
// Empty DataFrame
// Columns: [worker, day, hours]
// Index: []
edf.print();
// ╔════════════╗
// ║ ║
// ╚════════════╝
// - I would expect something like:
// Empty DataFrame
// Columns: [worker, day, hours]
// Index: []
df.ctypes.print();
// ╔════════╤════════╗
// ║ worker │ string ║
// ╟────────┼────────╢
// ║ day │ string ║
// ╟────────┼────────╢
// ║ hours │ int32 ║
// ╚════════╧════════╝
// - Printing as expected
df_filt.ctypes.print();
// Uncaught Error: Table must define at least one row.
// validateTableData validateTableData.js:10
// table table.js:15
// toString series.ts:1447
// print generic.ts:480
// - I would expect something like:
// ╔════════╤════════╗
// ║ worker │ string ║
// ╟────────┼────────╢
// ║ day │ string ║
// ╟────────┼────────╢
// ║ hours │ int32 ║
// ╚════════╧════════╝
edf.ctypes.print();
// Uncaught Error: Table must define at least one row.
// validateTableData validateTableData.js:10
// table table.js:15
// toString series.ts:1447
// print generic.ts:480
// - I would expect something like:
// Series([], dtype: object)