Questions tagged [tabulate]

Count or tally of named items in an object or structure.

Various languages will have different functions for this operation. "table" or "crosstabs" are two such examples. The output may be multi-dimensional.

168 questions
11
votes
7 answers

Is there an efficient alternative to table()?

I use the following command: table(factor("list",levels=1:"n") with "list": (example) a = c(1,3,4,4,3) and levels = 1:5, to also take the 2 and 5 into consideration. For really big datasets, my code seems to be very ineffective. Does anyone know a…
elmoBlue
  • 145
  • 5
9
votes
2 answers

Python tabulate: to have multiple header with merged cell

Is there a way to specify multiple headers with merged cells in python? example dataset: from tabulate import tabulate cols = ["ID", "Config\nA", "Config\nB", "Config\nC", "Config\nD", "Oth"] rows = [[ "0x0", "2", "0", "0", "4", "3"], […
kiki
  • 205
  • 1
  • 6
  • 15
8
votes
3 answers

How to use tabulate to format number with thousand separator and right align

I am using tabulate (https://pypi.org/project/tabulate/) and I want to format a number column with thousand separator and right align it. This is what I have done and it doesn't right align my column. import pandas as pd rom tabulate import…
Sean Nguyen
  • 12,528
  • 22
  • 74
  • 113
4
votes
3 answers

How can I specify the amount of spaces between columns by using tabulate module in python

Id like to know if there is some argument I can pass to tabulate module and specify the quantity of empty spaces between columns. I can see there are 2 spaces by default but I didnt find how do manipulate that. This is script example. from tabulate…
enrique-es
  • 41
  • 1
  • 5
4
votes
1 answer

Add header and text color in HTML table email body based on disk usage condition using Python

I am sending out an html table in an email body using python. The html table consists of disk usage and I need to add the header (first row) and text in red in the table when disk usage is above 80 percent. This is the code I'm using that works to…
ayuuk ja'ay
  • 382
  • 1
  • 3
  • 13
4
votes
2 answers

Python tabulate not writing to text file correctly

Am trying to tabulate a simple list into a text file formatted using tabulate(), fancy_grid format is what i want and it prints alright in the console, however upon writing to text file, I get the error below. Removing the argument…
Johnn Kaita
  • 432
  • 1
  • 3
  • 13
4
votes
0 answers

How to do subtotal using tabulate in python

I am using tabulate in my program to get decision table as depicted below. What i want to achieve to get subtotal on both column side and row side. Is that possible in python +-------+----------+---------+----------+---------+----------+ | Env | …
Koushur
  • 167
  • 1
  • 9
4
votes
2 answers

Printing dict as tabular Data

I'm trying to print a python dict in tabular format but facing difficulty in working with dict. Following is my dict: board_dict = { 'Done': { 'point': 0.0, 'items': 1 }, 'Doing': { …
DonOfDen
  • 3,968
  • 11
  • 62
  • 112
4
votes
1 answer

tabulate: define floatfmt for each column

I am using tabulate 0.75 to generate LaTeX tables. The function tabulate which generates my tables has a built-in function to format the input. But I want to define the amount of decimals for every column itself. For e.g. a b 18.12 16 17.47 …
lrsp
  • 1,213
  • 10
  • 18
3
votes
1 answer

Gitlab CI breaks line in Python script output

I want to display a table in Gitlab CI log using python script. I check the script locally and it displays the table correctly, but when I run the script in gitlab CI, it breaks the line, although if you try to echo any long line, it will output it…
RMNTRVN
  • 63
  • 1
  • 5
3
votes
1 answer

print multi-index dataframe with tabulate

How can one print a multi-index Dataframe such as the one below: import numpy as np import tabulate import pandas as pd df = pd.DataFrame(np.random.randn(4, 3), index=pd.MultiIndex.from_product([["foo", "bar"], …
sluque
  • 495
  • 4
  • 12
3
votes
1 answer

How to preserve trailing zeros?

I'm outputting a pandas dataframe to a report I'm writing, which is easy as you can now do df.to_markdown() to convert the dataframe to a markdown table, and then pandoc can generate the report. And we can control the specific formatting details…
Peter Prescott
  • 768
  • 8
  • 16
3
votes
1 answer

Python - HTML - Send HTML Table with CSS Style

I'm trying to send a email with a table as a body with some CSS configurations. For that I have the following code: import csv from tabulate import tabulate from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText import…
Pedro Alves
  • 1,004
  • 1
  • 21
  • 47
3
votes
2 answers

Python Tabulate format only one float column

I'm using the tabulate module to print a fixed width file and I have one column that I need formatted in such a way that there are 19 places to the left of the decimal and 2 places to the right of the decimal. import pandas as pd from tabulate…
Pete M
  • 154
  • 3
  • 8
3
votes
1 answer

Print in tabulated form

How can I print this in tabulated form? listex = range(nOfYears) counter = 1 for i in listex: if i ==0: print counter, '\t',startingBalance,'\t', amountofinterest, '\t', next_balance previous_balance = next_balance …
abdullah
  • 145
  • 1
  • 1
  • 8
1
2 3
11 12