-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Printing vectors of NamedTuples as a markdown table #24627
Comments
I think this is a good idea. The usual printing of arrays of named tuples is pretty annoying, repeating the names on every line. This also allows implementing things like #12131. What's your concern, @ararslan ? One issue is that we don't want too many different ways of printing tables. We should perhaps move DataFrames' printing code into Base as a |
My concern is that it's too specific; arrays of named tuples could potentially be used for things other than table-like structures. Plus, what do we do if a given element in the array has different names than the others? That would mess up the table formatting. And it would be weirdly inconsistent to print things nicely only in the case of an array where each element has the same set of names. |
I think you should be able to tell whether or not the names are consistent from the type signature alone. |
Yes, but that doesn't change or address anything I said above. |
I don't see it as inconsistent, since having the same names is what makes the nicer printing make sense. Similar to how we will print the type of each element if the array is heterogeneous, but not if all elements have the same type. |
?
|
Well, that's how it should work; see #24651. It doesn't apply to all types since many types like strings don't ever have a type as part of their representation. |
I'm not sure yet, but I think I prefer a dedicated |
How about a table struct wrapper for a vector named tuples which prints as a markdown table? |
An updated version now that the windows 0.7 binaries are out:
|
Still think this might be nice, but I guess a little unexpected |
A vector of NamedTuples has the potential to become a "lightweight table". See #12131 (comment). To that end, printing a vector of NamedTuples with the same fields as a markdown table is a good start. This is a convenient way to view the contents of a vector of NamedTuples regardless. In Keys.jl I had the beginning of the code for this. I was waiting for a windows binary to come out with NamedTuples in order to be able to port the code, but I got bored. So anyway here's the code I had below. I'm somewhat indifferent about the actual implementation details.
The text was updated successfully, but these errors were encountered: