Questions tagged [prettytable]

A simple Python library for easily displaying tabular data in a visually appealing ASCII table format.

PrettyTable is a simple Python library designed to make it quick and easy to represent tabular data in visually appealing ASCII tables. It was inspired by the ASCII tables used in the PostgreSQL shell psql.

PrettyTable allows for selection of which columns are to be printed, independent alignment of columns (left or right justified or centred) and printing of “sub-tables” by specifying a row range.

https://pypi.python.org/pypi/PrettyTable

155 questions
1
vote
1 answer

How to remove rows with value less than 0% in Prettytable

I am trying to get the no. of colors in an Image put due to the looping through every single pixel it is showing several colors with values less than 0%. I am trying to remove rows with percentage value less than 0% in the following list showing in…
A_K
  • 731
  • 3
  • 15
  • 40
1
vote
1 answer

Is it possible to print a table of a 'for loop' at the same position without moving ahead the lines of the Terminal using python?

Here is a code example to print some numbers at the same cursor position of the console, without moving the characters from place. Code Example from sys import stdout from time import sleep for i in range(1,20): stdout.write("\r%d" % i) …
Thinker-101
  • 554
  • 5
  • 19
1
vote
1 answer

Creating a table with prettytable from list of dictionaries

I have a list of dictionaries in a form like shown below: mylist=[{'M': 0.02788376633371408, 'G': 0.06911804019734125, 'N': 0.03952819565622443, 'K': 0.07071475441708995, 'Q': 0.03835921614374478, 'P': 0.03663450555326026, 'Y': 0.0349154656880615,…
ryszard eggink
  • 315
  • 3
  • 14
1
vote
1 answer

Python Error: ModuleNotFoundError: No module named ''

I am trying to import several modules that I know for a fact that are installed, but I am getting the ModuleNotFoundError: No module named '' error. $ sudo -H pip install numpy Requirement already satisfied: numpy in…
daquezada
  • 1,017
  • 2
  • 10
  • 15
1
vote
1 answer

Setting column width for columns in prettytable

I have to print more than one table using prettytable and also the size each column should match with the size of corresponding column in other tables also. I didn't find any function where I can specify the width of each column. The column width is…
1
vote
1 answer

How to add borderline between row items in prettytable?

I'm using python prettytable, and want to add borderlines between row items. Is there any idea? Or can I at least add padding between the rows? Thanks.
Mark Yoon
  • 330
  • 4
  • 17
1
vote
1 answer

How to solve the FunctionError and MapError

Python 3.6 pycharm import prettytable as pt import numpy as np import pandas as pd a=np.random.randn(30,2) b=a.round(2) df=pd.DataFrame(b) df.columns=['data1','data2'] tb = pt.PrettyTable() def func1(columns): def func2(column): return…
XY XUE
  • 123
  • 1
  • 2
  • 6
1
vote
6 answers

How to Create Footer for Python PrettyTable

I'm looking to add a footer to my PrettyTable, totalling the data stored in the rows above. I've created a count in the script, but I'd like to add this into the table. The code I have to create the table below is as follows (.add_row is in a…
DeltaKilo
  • 113
  • 3
  • 12
1
vote
1 answer

python: Read a table from file (created from prettytable) and mantain spaces

Let's say I have the following file.txt $ cat file.txt +-----------+------+------------+-----------------+ | City name | Area | Population | Annual Rainfall | +-----------+------+------------+-----------------+ | Adelaide | 1295 | 1158259 | …
Rodrigo P
  • 39
  • 4
1
vote
2 answers

Python PrettyTable alignment

I used PrettyTable module in the Python 3.6,but the output table is not aligned (like the red rectangle in the picture).I have searched this issue on the internet,but no good answer. Is it because there're some Chinese language in the table? All…
Ringo
  • 1,173
  • 1
  • 12
  • 25
1
vote
1 answer

Python: appending column to existing table in PrettyTable

Let's say I have this code: from prettytable import PrettyTable f = open("test.txt", "w") t = PrettyTable() def main(): animal = input("Enter an animal: ") car = input("Enter a car: ") column_names = ["animal", "car"] …
The Messenger
  • 13
  • 1
  • 6
1
vote
1 answer

Python PrettyTable with multiple header/ title

I am able to create a python PrettyTable with a title and table fields. But, I want to create multiple sections in a single table i.e have multiple header (or html rowspan/ colspan to merge cells inorder to create sections). Any pointers for…
iDev
  • 2,163
  • 10
  • 39
  • 64
1
vote
1 answer

Python prettytable get_string error

I have a pandas data frame like >>> df Out[126]: score id 0 0.999989 654153 1 0.992971 941351 2 0.979518 701608 3 0.972667 564000 4 0.936928 999843 and want to convert to a prettytable (in order to write to a text…
mccandar
  • 778
  • 8
  • 16
1
vote
1 answer

PrettyTable format title

I want to format a title for prettytable with values but I can't. from prettytable import PrettyTable name = "table 1" table = PrettyTable() owntitle = "table name is {}".format(str(name)) table.title = owntitle table.field_names =…
anna
  • 91
  • 3
  • 10
1
vote
0 answers

how to display a certain subset of data on prettytable in a descending order

i have a PrettyTable with two headers and over 500 rows, the structure is like this Email Address number of contacts aaa@goo.com 99 aaa@foo.com 123 and my code: table =pt.PrettyTable(["Email Address", "Number of Contacts"]) …
artre
  • 311
  • 4
  • 14