Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python generate table

# first run "pip install tabulate" in terminal
# Create Table with Headers
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))

Team      Points
------  --------
Mavs          99
Suns          91
Spurs         94
Nets          88
Comment

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 │
╘════╧════════╧══════════╛
Comment

python generate table

# first run "pip install tabulate" in terminal
# Create Table with Fancy Grid
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"))

╒════════╤══════════╕
│ Team   │   Points │
╞════════╪══════════╡
│ Mavs   │       99 │
├────────┼──────────┤
│ Suns   │       91 │
├────────┼──────────┤
│ Spurs  │       94 │
├────────┼──────────┤
│ Nets   │       88 │
╘════════╧══════════╛
Comment

generate table python

def tableNum(num):
    for i in range(1,11):
        print(f'{num} * {i} = {num*i}')
    
tableNum(2)
Comment

PREVIOUS NEXT
Code Example
Python :: covariance matrix python 
Python :: python flatten dict 
Python :: panda get rows with date range 
Python :: debugging pytest in vscode 
Python :: plotly grid lines color 
Python :: convert grayscale to rgb python 
Python :: python first day of last month 
Python :: check pip version 
Python :: seaborn create a correlation matrix 
Python :: docker python 3.8 ubuntu 
Python :: subplot matplotlib set limits 
Python :: how to do pandas profiling 
Python :: python name of current file 
Python :: how to loop the length of an array pytoh 
Python :: python url encoding 
Python :: insert picture into jupyter notebook 
Python :: install os python 
Python :: using regex validators in django models 
Python :: tkinter background color 
Python :: matplotlib histogram 
Python :: select DF columns python 
Python :: how to convert kg to g using python 
Python :: button images in tkinter 
Python :: matplotlib set dpi 
Python :: argument sequence in python function 
Python :: python condition if dataype 
Python :: python image to pdf 
Python :: mnist fashion dataset 
Python :: read image python 
Python :: multiple args for pandas apply 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =