mirror of
https://github.com/KevinMidboe/tableprint.git
synced 2025-10-29 18:00:16 +00:00
added frame() helper function to print a pandas DataFrame
This commit is contained in:
4
setup.py
4
setup.py
@@ -14,7 +14,7 @@ setup(
|
|||||||
# Versions should comply with PEP440. For a discussion on single-sourcing
|
# Versions should comply with PEP440. For a discussion on single-sourcing
|
||||||
# the version across setup.py and the project code, see
|
# the version across setup.py and the project code, see
|
||||||
# https://packaging.python.org/en/latest/single_source_version.html
|
# https://packaging.python.org/en/latest/single_source_version.html
|
||||||
version='0.1.0',
|
version='0.1.1',
|
||||||
|
|
||||||
description='Pretty ASCII printing of tabular data',
|
description='Pretty ASCII printing of tabular data',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
@@ -65,7 +65,7 @@ setup(
|
|||||||
# project is installed. For an analysis of "install_requires" vs pip's
|
# project is installed. For an analysis of "install_requires" vs pip's
|
||||||
# requirements files see:
|
# requirements files see:
|
||||||
# https://packaging.python.org/en/latest/requirements.html
|
# https://packaging.python.org/en/latest/requirements.html
|
||||||
install_requires=[],
|
install_requires=['pandas'],
|
||||||
|
|
||||||
# List additional groups of dependencies here (e.g. development dependencies).
|
# List additional groups of dependencies here (e.g. development dependencies).
|
||||||
# You can install these using the following syntax, for example:
|
# You can install these using the following syntax, for example:
|
||||||
|
|||||||
@@ -3,8 +3,35 @@ Module to nicely format ASCII table rows for display
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# imports
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
# exports
|
# exports
|
||||||
__all__ = ['table', 'row', 'header']
|
__all__ = ['table', 'row', 'header', 'frame']
|
||||||
|
|
||||||
|
|
||||||
|
def frame(df, options=None):
|
||||||
|
"""
|
||||||
|
Print an ASCII table using the given pandas DataFrame
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
df : DataFrame
|
||||||
|
A pandas DataFrame with consisting of the table to print
|
||||||
|
|
||||||
|
options : dict
|
||||||
|
A dictionary of options. Defaults:
|
||||||
|
{
|
||||||
|
'column_width' : 10, # the width of each column in the table
|
||||||
|
'outer_char' : '|', # the character defining the outer border of the table
|
||||||
|
'corner_char' : '+', # printed at the junctions of the table lines
|
||||||
|
'line_char' : '-', # character as part of each horizontal rule
|
||||||
|
'precision' : '2f' # precision string for formatting numbers
|
||||||
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
table(np.array(df), list(df.columns), options)
|
||||||
|
|
||||||
|
|
||||||
def table(data, headers, options=None):
|
def table(data, headers, options=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user