Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python generate table

# first run "pip install tabulate" in terminal
# Create Table with Index Column
from tabulate import tabulate
#create data
data = [["Mavs", 99], 
        ["Suns", 91], 
        ["Spurs", 94], 
        ["Nets", 88]]
  
#define header names
col_names = ["Team", "Points"]
  
#display table
print(tabulate(data, headers=col_names, tablefmt="fancy_grid", showindex="always"))

╒════╤════════╤══════════╕
│    │ Team   │   Points │
╞════╪════════╪══════════╡
│  0 │ Mavs   │       99 │
├────┼────────┼──────────┤
│  1 │ Suns   │       91 │
├────┼────────┼──────────┤
│  2 │ Spurs  │       94 │
├────┼────────┼──────────┤
│  3 │ Nets   │       88 │
╘════╧════════╧══════════╛
 
PREVIOUS NEXT
Tagged: #python #generate #table
ADD COMMENT
Topic
Name
1+4 =