larray.Array.dump
- Array.dump(self, header=True, wide=True, value_name='value', light=False, axes_names=True, na_repr='as_is', maxlines=-1, edgeitems=5)[source]
Dump array as a 2D nested list. This is especially useful when writing to an Excel sheet via open_excel().
- Parameters
- headerbool
Whether to output axes names and labels.
- wideboolean, optional
Whether to write arrays in “wide” format. If True, arrays are exported with the last axis represented horizontally. If False, arrays are exported in “narrow” format: one column per axis plus one value column. Not used if header=False. Defaults to True.
- value_namestr, optional
Name of the column containing the values (last column) when wide=False (see above). Not used if header=False. Defaults to ‘value’.
- lightbool, optional
Whether to hide repeated labels. In other words, only show a label if it is different from the previous one. Defaults to False.
- axes_namesbool or ‘except_last’, optional
Assuming header is True, whether to include axes names. If axes_names is ‘except_last’, all axes names will be included except the last. Defaults to True.
- na_reprany scalar, optional
Replace missing values (NaN floats) by this value. Defaults to ‘as_is’ (do not do any replacement).
- maxlinesint, optional
Maximum number of lines to show. Defaults to -1 (all lines are shown).
- edgeitemsint, optional
If number of lines to display is greater than maxlines, only the first and last edgeitems lines are displayed. Only active if maxlines is not -1. Defaults to 5.
- Returns
- 2D nested list of builtin Python values or None for 0d arrays
Examples
>>> arr = ndtest((2, 2, 2)) >>> arr.dump() [['a', 'b\\c', 'c0', 'c1'], ['a0', 'b0', 0, 1], ['a0', 'b1', 2, 3], ['a1', 'b0', 4, 5], ['a1', 'b1', 6, 7]] >>> arr.dump(axes_names=False) [['', '', 'c0', 'c1'], ['a0', 'b0', 0, 1], ['a0', 'b1', 2, 3], ['a1', 'b0', 4, 5], ['a1', 'b1', 6, 7]] >>> arr.dump(axes_names='except_last') [['a', 'b', 'c0', 'c1'], ['a0', 'b0', 0, 1], ['a0', 'b1', 2, 3], ['a1', 'b0', 4, 5], ['a1', 'b1', 6, 7]] >>> arr.dump(light=True) [['a', 'b\\c', 'c0', 'c1'], ['a0', 'b0', 0, 1], ['', 'b1', 2, 3], ['a1', 'b0', 4, 5], ['', 'b1', 6, 7]] >>> arr.dump(wide=False, value_name='data') [['a', 'b', 'c', 'data'], ['a0', 'b0', 'c0', 0], ['a0', 'b0', 'c1', 1], ['a0', 'b1', 'c0', 2], ['a0', 'b1', 'c1', 3], ['a1', 'b0', 'c0', 4], ['a1', 'b0', 'c1', 5], ['a1', 'b1', 'c0', 6], ['a1', 'b1', 'c1', 7]] >>> arr.dump(maxlines=3, edgeitems=1) [['a', 'b\\c', 'c0', 'c1'], ['a0', 'b0', 0, 1], ['...', '...', '...', '...'], ['a1', 'b1', 6, 7]]