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

how to make table using python

from prettytable import PrettyTable
A = PrettyTable()
A.add_column("Pokimon",["wartortle"])
A.add_column("Type",["Water attack"])
print(A)
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 :: Python enumerate Using enumerate() 
Python :: how to use re.sub 
Python :: # /usr/bin/env python windows 
Python :: how to use for in python 
Python :: pytest fixtures scope explained 
Python :: how to save plot in matplotlib 
Python :: df mask 
Python :: Python - How To Concatenate List of String 
Python :: convert word to pdf python 
Python :: python trace table 
Python :: get midnight of current day python 
Python :: tuple to string python 
Python :: typeerror: 
Python :: 2nd to last index python 
Python :: examples of function in python 
Python :: create tuples in pandas 
Python :: save variable to use in other jupyter notebook 
Python :: python loop 
Python :: python numpy array subtract 
Python :: desktop notifier in python 
Python :: additionner liste python 
Python :: remove python 2.7 centos 7 
Python :: set default palette seaborn 
Python :: convert tuple to int 
Python :: get_queryset django rest framework 
Python :: prime numbers upto n in python 
Python :: numpy.where 
Python :: drop row pandas column value not a number 
Python :: encode url 
Python :: python version of settimout 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =