mirror of
https://github.com/KevinMidboe/tableprint.git
synced 2025-10-29 01:40:17 +00:00
Updated docs
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2015 Niru Maheswaranathan
|
Copyright (c) 2015-2016 Niru Maheswaranathan
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ Quickstart
|
|||||||
----------
|
----------
|
||||||
|
|
||||||
Now let's see what we can do. Tableprint offers two functions that print a table directly,
|
Now let's see what we can do. Tableprint offers two functions that print a table directly,
|
||||||
``tableprint.table`` and ``tableprint.frame``. The first takes a numpy array and a list of
|
``tableprint.table`` and ``tableprint.dataframe``. The first takes a numpy array and a list of
|
||||||
headers, whereas the second takes a pandas DataFrame as input. For example, you can do the following:
|
headers, whereas the second takes a pandas DataFrame as input. For example, you can do the following:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
@@ -26,14 +26,12 @@ headers, whereas the second takes a pandas DataFrame as input. For example, you
|
|||||||
>>> tableprint.table(np.random.randn(10,3), ['A', 'B', 'C'])
|
>>> tableprint.table(np.random.randn(10,3), ['A', 'B', 'C'])
|
||||||
|
|
||||||
If you want to append to a table on the fly, you can use the functions ``tableprint.header``,
|
If you want to append to a table on the fly, you can use the functions ``tableprint.header``,
|
||||||
``tableprint.row``, and ``tableprint.hr``. These functions return an ASCII formatted string
|
``tableprint.row``, and finally ``tableprint.bottom``. These functions return a formatted string
|
||||||
given a list of headers, an array of data, and a number of columns, respectively. For example
|
given a list of headers, an array of data, and a number of columns, respectively. For example
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
>>> print(tableprint.hr(3))
|
|
||||||
>>> print(tableprint.header(['A', 'B', 'C']))
|
>>> print(tableprint.header(['A', 'B', 'C']))
|
||||||
>>> print(tableprint.hr(3))
|
|
||||||
>>> for ix in range(10):
|
>>> for ix in range(10):
|
||||||
|
|
||||||
# insert time-intensive data collection here
|
# insert time-intensive data collection here
|
||||||
@@ -42,7 +40,16 @@ given a list of headers, an array of data, and a number of columns, respectively
|
|||||||
# print data to stdout
|
# print data to stdout
|
||||||
print(tableprint.row(data), flush=True)
|
print(tableprint.row(data), flush=True)
|
||||||
|
|
||||||
>>> print(tableprint.hr(3))
|
>>> print(tableprint.bottom(3))
|
||||||
|
|
||||||
|
Sometimes you just want to print a fancy string but without any numbers. In that case, you can use the ``tableprint.banner`` function:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
>> tableprint.banner("Hello, World!")
|
||||||
|
|
||||||
|
All of these functions take two optional keyword arguments, a ``width`` that defines the width of each column and a ``style`` that specifies
|
||||||
|
what unicode or ascii characters to use to build the table. The available styles are: ``round`` (default), ``fancy_grid``, ``grid``, ``clean``, and ``block``.
|
||||||
|
|
||||||
API
|
API
|
||||||
---
|
---
|
||||||
@@ -50,8 +57,10 @@ API
|
|||||||
Tableprint comes with a number of options, these are fully described below:
|
Tableprint comes with a number of options, these are fully described below:
|
||||||
|
|
||||||
.. autofunction:: tableprint.table
|
.. autofunction:: tableprint.table
|
||||||
.. autofunction:: tableprint.frame
|
.. autofunction:: tableprint.dataframe
|
||||||
|
.. autofunction:: tableprint.banner
|
||||||
.. autofunction:: tableprint.header
|
.. autofunction:: tableprint.header
|
||||||
.. autofunction:: tableprint.row
|
.. autofunction:: tableprint.row
|
||||||
.. autofunction:: tableprint.hr
|
.. autofunction:: tableprint.top
|
||||||
|
.. autofunction:: tableprint.bottom
|
||||||
.. autofunction:: tableprint.humantime
|
.. autofunction:: tableprint.humantime
|
||||||
|
|||||||
Reference in New Issue
Block a user