You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary: I want to pass a list of dicts as the data, and a list of keys for headers. I don't want to full list of keys in the data as headers, I want a shorter list, in a different order.
In the documentation:
The following tabular data types are supported:
...
dict of iterables (keys as columns)
...
The headers parameter requires either a special keyword (e.g., "keys"), or a dict of column keys. I already have a list of column keys. (In a bizarre complication, the code converts this dict of column keys to a list? But doesn't support a list of column keys directly? WTF?) [I agree, it's nice that the header dict is converted to a list for me.)
My header list is not always the full list of column keys, as the full data is collected first, then a decision is made on which columns to output.
A workaround is to convert my list of column keys to a dict, so the code can convert it back?
The text was updated successfully, but these errors were encountered:
headers=some_dict, but the keys are not limited to the keys or values in some_dict, they are in fact ALL of the keys present in the data! (Again, WTF?)
In this scenario, headers only provides a mapping from actual key names to output column names. If there is no matching key in the headers dict, the original key from the original data is used. ¯\(ツ)/¯
elif isinstance(headers, dict):
# a dict of headers for a list of dicts
headers = [headers.get(k, k) for k in keys]
headers = list(map(_text_type, headers))
So I also need to filter out key/value pairs that I don't want in the output.
Summary: I want to pass a list of dicts as the data, and a list of keys for headers. I don't want to full list of keys in the data as headers, I want a shorter list, in a different order.
In the documentation:
The headers parameter requires either a special keyword (e.g., "keys"), or a dict of column keys. I already have a list of column keys. (In a bizarre complication, the code converts this dict of column keys to a list? But doesn't support a list of column keys directly? WTF?) [I agree, it's nice that the header dict is converted to a list for me.)
My header list is not always the full list of column keys, as the full data is collected first, then a decision is made on which columns to output.
A workaround is to convert my list of column keys to a dict, so the code can convert it back?
The text was updated successfully, but these errors were encountered: