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
2
votes
4 answers

Add a factor level to a table

I have built a contingency table from a column in a dataframe: > dat <- data.frame(x = c(1, 1, 3)) > table(dat) x 1 3 2 1 I want to add a "column" to the table for the missing factor levels (in this case "2") with a count of 0. The result should…
user19050587
2
votes
0 answers

Tabula-py not extracting tables correctly

I was building an API that uses tabula to extract table from a pdf. I built the API on the windows machine and deployed it on ubuntu 20. On the windows machine the extraction was flawless, and I was able to perform all the necessary steps. However,…
abhi
  • 337
  • 1
  • 3
  • 12
2
votes
1 answer

How to break and left align long lines of text in a dataframe?

Trying to break long lines on ';' (semicolon) AND left align the output of that column # Python version 3.9.12.final.0 import pandas as pd # Pandas version 1.4.2 import numpy as np from tabulate import tabulate from IPython.display import HTML …
Andrew Ward
  • 171
  • 2
  • 13
2
votes
1 answer

Properly handling missing values and formatting for pandas data frame printed to tabulate

In the following scenario, I would like to: Replace the missing values with a custom character, for example - Apply custom formatting with respect to numbers Problem I seem to be able to achieve only one of those goals. If I use the code below, I…
Konrad
  • 17,740
  • 16
  • 106
  • 167
2
votes
2 answers

How to display pretty tables in terminal with tabulate python package?

I am have simple CLI app written in python with argparse module. Basically I am fetching some cryptocurrency data with external api, I transform it into pandas dataframe and print it with tabulate module. But I have issue with printing tables in my…
Jakub Pluta
  • 147
  • 5
  • 13
2
votes
0 answers

Export table of multiple categorical variables with same categories to excel

I need to export an overview of several categorical variables to Excel. Even though it appears so trivial there have been roadblocks a lot by now. I have been looking at different options, like tabout, tab2xl or putexcel but because of the…
lea
  • 21
  • 2
2
votes
2 answers

pandas.DataFrame.to_markdown transform large int to float

pandas.DataFrame.to_markdown transforms large int to float. Is it a bug or a feature? Are there any solutions? >>> df = pd.DataFrame({"A": [123456, 123456]}) >>> print(df.to_markdown()) | | A | |---:|-------:| | 0 | 123456 | | 1 | 123456…
Marc
  • 1,630
  • 1
  • 15
  • 17
2
votes
3 answers

Error while using tabulate "TypeError: 'int' object is not iterable"

so, I was using tabulate to format my data in my latest project. But, it keeps giving this error and I'm not able to understand the reason behind it. Here's the code: from datetime import date from tabulate import tabulate records = [] …
2
votes
1 answer

python tabulate: display blank cell for specific values

I have this numpy array import numpy as np from tabulate import tabulate data = np.array([[1,2], [3,4]]) data2 = tabulate(data, tablefmt='fancy_grid') print(data2) ╒═══╤═══╕ │ 1 │ 2 │ ├───┼───┤ │ 3 │ 4 │ ╘═══╧═══╛ I'm interested in a cleaner…
tamtam
  • 641
  • 9
  • 24
2
votes
1 answer

Standardized tables with repeated labels using PROC TABULATE in SAS

In SAS, I need a PROC TABULATE where labels are repeated so that it's easier on Excel to find them using INDEX-MATCH. Here is an example with sashelp.cars. The first PROC TABULATE has the advantage of having repeating labels, which is needed for the…
Siva Kg
  • 59
  • 8
2
votes
1 answer

My imported .txt table does not line up correctly with the headers (Python)

So basically I have to import a preset .txt file and everything works fine except for the one small thing that the preset headers that are in the code don't line up with the .txt file data properly. import csv from tabulate import tabulate as…
Clique
  • 47
  • 2
  • 6
2
votes
1 answer

How to fix 'argument must support iteration' for tabulate on PyMySQL output

I am using PyMySQL to perform select queries from a DB and I wanted to use tabulate to format the output of those queries. I have been able to get tabulate to work correctly when the SQL query involves only selecting one column, but I can't get…
user1787207
2
votes
1 answer

TypeError: 'headers' is an invalid keyword argument for print()

I recently installed tabulate onto conda and I am trying to tabulate my results with print syntax Source: Printing Lists as Tabular Data but I am getting "TypeError: 'headers' is an invalid keyword argument for print()" I have tried…
user1234
  • 257
  • 2
  • 13
2
votes
2 answers

Relate elements in table form from Json file with jq

I'm new to jq and I have the following code to obtain tabulated the values for each element called Abc: ["Abc"], ( .. | objects | select(has("Abc")) | [.["Abc"]] ) | @tsv This is the current output I get: "Abc" "4" "2" "1" "9" "3" "2" "4" "9" I…
Ger Cas
  • 2,188
  • 2
  • 18
  • 45
1
vote
1 answer

Can I calculate the mean/mode of a variable (by another variable) and tabulate in R?

I want to find the mean (for numerical variables) and mode (for character variables) for each of the variables under column "trait_name" for each unique "taxon_name". I would then like to tabulate these values. This is what my dataframe looks like…
1
2
3
11 12