Skip to content

Commit 640f40d

Browse files
committed
update README, version bump to version 0.5
1 parent 2ea9539 commit 640f40d

File tree

3 files changed

+44
-20
lines changed

3 files changed

+44
-20
lines changed

README.rst

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ Installation
2828
Usage
2929
-----
3030

31-
The module provides just one function, ``tabulate``, which takes a list
32-
of lists or a similarly shaped data structure, and outputs a nicely
33-
formatted plain-text table::
31+
The module provides just one function, ``tabulate``, which takes a
32+
list of lists or another tabular data type as the first argument,
33+
and outputs a nicely formatted plain-text table::
3434

3535
>>> from tabulate import tabulate
3636

@@ -44,18 +44,21 @@ formatted plain-text table::
4444
Mars 3390 641.85
4545
----- ------ -------------
4646

47-
``tabulate`` can pretty-print two-dimensional NumPy arrays too.
47+
The following tabular data types are supported:
4848

49-
Examples in this file use Python2. Tabulate supports Python3 too.
49+
* list of lists or another iterable of iterables
50+
* dict of iterables
51+
* two-dimensional NumPy array
52+
* pandas.DataFrame
53+
54+
Examples in this file use Python2. Tabulate supports Python3 too (Python >= 3.3).
5055

5156

5257
Headers
5358
~~~~~~~
5459

55-
If function ``tabulate`` receives two arguments, it considers the
56-
second argument to be a list of column headers.
57-
The list of headers may be passed also out-of-order with a named
58-
argument ``headers=...``::
60+
The second optional argument named ``headers`` defines a list of
61+
column headers to be used::
5962

6063
>>> print tabulate(table, headers=["Planet","R (km)", "mass (x 10^29 kg)"])
6164
Planet R (km) mass (x 10^29 kg)
@@ -65,6 +68,26 @@ argument ``headers=...``::
6568
Moon 1737 73.5
6669
Mars 3390 641.85
6770

71+
If `headers="firstrow", then the first row of data is used::
72+
73+
>>> print tabulate([["Name","Age"],["Alice",24],["Bob",19]],
74+
... headers="firstrow")
75+
Name Age
76+
------ -----
77+
Alice 24
78+
Bob 19
79+
80+
81+
If `headers="keys"`, then the keys of a dictionary/dataframe,
82+
or column indices are used::
83+
84+
>>> print tabulate({"Name": ["Alice", "Bob"],
85+
... "Age": [24, 19]}, headers="keys")
86+
Age Name
87+
----- ------
88+
24 Alice
89+
19 Bob
90+
6891

6992
Table format
7093
~~~~~~~~~~~~
@@ -232,6 +255,7 @@ Performance considerations
232255
Such features as decimal point alignment and trying to parse everything
233256
as a number imply that ``tabulate``:
234257

258+
* has to "guess" how to print a particular tabular data type
235259
* needs to keep the entire table in-memory
236260
* has to "transpose" the table twice
237261
* does much more work than it may appear
@@ -244,27 +268,27 @@ separator.
244268

245269
In the same time ``tabulate`` is comparable to other table
246270
pretty-printers. Given a 10x10 table (a list of lists) of mixed text
247-
and numeric data, ``tabulate`` appears to be slightly slower than
248-
``asciitable``, and much faster than ``PrettyTable`` and
249-
``texttable``
271+
and numeric data, ``tabulate`` appears to be slower than
272+
``asciitable``, and faster than ``PrettyTable`` and ``texttable``
250273

251274
::
252275

253276
=========================== ========== ===========
254277
Table formatter time, μs rel. time
255278
=========================== ========== ===========
256-
join with tabs and newlines 22.7 1.0
257-
csv to StringIO 31.9 1.4
258-
asciitable (0.8.0) 841.3 37.0
259-
tabulate (0.4.4) 1109.8 48.9
260-
PrettyTable (0.7.1) 3795.6 167.1
261-
texttable (0.8.1) 4032.9 177.5
279+
join with tabs and newlines 23.0 1.0
280+
csv to StringIO 32.4 1.4
281+
asciitable (0.8.0) 842.0 36.7
282+
tabulate (0.5) 1892.9 82.5
283+
PrettyTable (0.7.1) 3711.1 161.7
284+
texttable (0.8.1) 3927.5 171.1
262285
=========================== ========== ===========
263286

264287

265288
Version history
266289
---------------
267290

291+
- 0.5: ANSI color sequences. Printing dicts of iterables and Pandas' dataframes.
268292
- 0.4.4: Python 2.6 support
269293
- 0.4.3: Bug fix, None as a missing value
270294
- 0.4.2: Fix manifest file

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
LONG_DESCRIPTION = open("README.rst").read().replace("`_", "`")
99

1010
setup(name='tabulate',
11-
version='0.4.4',
11+
version='0.5',
1212
description='Pretty-print tabular data',
1313
long_description=LONG_DESCRIPTION,
1414
author='Sergey Astanin',

tabulate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828

2929
__all__ = ["tabulate"]
30-
__version__ = "0.4.4"
30+
__version__ = "0.5"
3131

3232

3333
Line = namedtuple("Line", ["begin", "hline", "sep", "end"])

0 commit comments

Comments
 (0)