<jupyter_start><jupyter_text>New to Plotly?Plotly's Python library is free and open source! [Get started](https://plot.ly/python/getting-started/) by downloading the client and [reading the primer](https://plot.ly/python/getting-started/).You can set up Plotly to work in [online](https://plot.ly/python/getting-started/initialization-for-online-plotting) or [offline](https://plot.ly/python/getting-started/initialization-for-offline-plotting) mode, or in [jupyter notebooks](https://plot.ly/python/getting-started/start-plotting-online).We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/python_cheat_sheet.pdf) (new!) to help you get started! Version CheckNote: Table traces are available in version 2.2.1+. Run  `pip install plotly --upgrade` to update your Plotly version<jupyter_code>import plotly
plotly.__version__<jupyter_output><empty_output><jupyter_text>Basic Table<jupyter_code>import plotly.plotly as py
import plotly.graph_objs as go

trace = go.Table(
    header=dict(values=['A Scores', 'B Scores']),
    cells=dict(values=[[100, 90, 80, 90],
                       [95, 85, 75, 95]]))

data = [trace] 
py.iplot(data, filename = 'basic_table')<jupyter_output><empty_output><jupyter_text>Styled Table<jupyter_code>import plotly.plotly as py
import plotly.graph_objs as go

trace = go.Table(
    header=dict(values=['A Scores', 'B Scores'],
                line = dict(color='#7D7F80'),
                fill = dict(color='#a1c3d1'),
                align = ['left'] * 5),
    cells=dict(values=[[100, 90, 80, 90],
                       [95, 85, 75, 95]],
               line = dict(color='#7D7F80'),
               fill = dict(color='#EDFAFF'),
               align = ['left'] * 5))

layout = dict(width=500, height=300)
data = [trace]
fig = dict(data=data, layout=layout)
py.iplot(fig, filename = 'styled_table')<jupyter_output><empty_output><jupyter_text>Use a Panda's Dataframe<jupyter_code>import plotly.plotly as py
import plotly.graph_objs as go

import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_usa_states.csv')

trace = go.Table(
    header=dict(values=list(df.columns),
                fill = dict(color='#C2D4FF'),
                align = ['left'] * 5),
    cells=dict(values=[df.Rank, df.State, df.Postal, df.Population],
               fill = dict(color='#F5F8FF'),
               align = ['left'] * 5))

data = [trace] 
py.iplot(data, filename = 'pandas_table')<jupyter_output><empty_output><jupyter_text>Changing Row and Column Size<jupyter_code>import plotly.plotly as py
import plotly.graph_objs as go

values = [[['Salaries', 'Office', 'Merchandise', 'Legal', '<b>TOTAL<br>EXPENSES</b>']],
[["Lorem ipsum dolor sit amet, tollit discere inermis pri ut. Eos ea iusto timeam, an prima laboramus vim. Id usu aeterno adversarium, summo mollis timeam vel ad",
  "Lorem ipsum dolor sit amet, tollit discere inermis pri ut. Eos ea iusto timeam, an prima laboramus vim. Id usu aeterno adversarium, summo mollis timeam vel ad",
  "Lorem ipsum dolor sit amet, tollit discere inermis pri ut. Eos ea iusto timeam, an prima laboramus vim. Id usu aeterno adversarium, summo mollis timeam vel ad",
  "Lorem ipsum dolor sit amet, tollit discere inermis pri ut. Eos ea iusto timeam, an prima laboramus vim. Id usu aeterno adversarium, summo mollis timeam vel ad",
  "Lorem ipsum dolor sit amet, tollit discere inermis pri ut. Eos ea iusto timeam, an prima laboramus vim. Id usu aeterno adversarium, summo mollis timeam vel ad"]]]


trace0 = go.Table(
  columnorder = [1,2],
  columnwidth = [80,400],
  header = dict(
    values = [['<b>EXPENSES</b><br>as of July 2017'],
                  ['<b>DESCRIPTION</b>']],
    line = dict(color = '#506784'),
    fill = dict(color = '#119DFF'),
    align = ['left','center'],
    font = dict(color = 'white', size = 12),
    height = 40
  ),
  cells = dict(
    values = values,
    line = dict(color = '#506784'),
    fill = dict(color = ['#25FEFD', 'white']),
    align = ['left', 'center'],
    font = dict(color = '#506784', size = 12),
    height = 30
    ))

data = [trace0]

py.iplot(data, filename = "Row and Column Size")<jupyter_output><empty_output><jupyter_text>Alternating Row Colors<jupyter_code>import plotly.plotly as py
import plotly.graph_objs as go

headerColor = 'grey'
rowEvenColor = 'lightgrey'
rowOddColor = 'white'

trace0 = go.Table(
  header = dict(
    values = [['<b>EXPENSES</b>'],
                  ['<b>Q1</b>'],
                  ['<b>Q2</b>'],
                  ['<b>Q3</b>'],
                  ['<b>Q4</b>']],
    line = dict(color = '#506784'),
    fill = dict(color = headerColor),
    align = ['left','center'],
    font = dict(color = 'white', size = 12)
  ),
  cells = dict(
    values = [
      [['Salaries', 'Office', 'Merchandise', 'Legal', '<b>TOTAL</b>']],
      [[1200000, 20000, 80000, 2000, 12120000]],
      [[1300000, 20000, 70000, 2000, 130902000]],
      [[1300000, 20000, 120000, 2000, 131222000]],
      [[1400000, 20000, 90000, 2000, 14102000]]],
    line = dict(color = '#506784'),
    fill = dict(color = [rowOddColor,rowEvenColor,rowOddColor, rowEvenColor,rowOddColor]),
    align = ['left', 'center'],
    font = dict(color = '#506784', size = 11)
    ))

data = [trace0]

py.iplot(data, filename = "alternating row colors")<jupyter_output><empty_output><jupyter_text>Row Color Based on Variable<jupyter_code>import plotly.plotly as py
import plotly.graph_objs as go

import pandas as pd
import colorlover as cl

colors = cl.scales['5']['seq']['Blues']
data = {'Year' : [2010, 2011, 2012, 2013, 2014],
        'Color' : colors}
df = pd.DataFrame(data)


trace0 = go.Table(
  header = dict(
    values = ["Color", "<b>YEAR</b>"],
    line = dict(color = 'white'),
    fill = dict(color = 'white'),
    align = ['center'],
    font = dict(color = 'black', size = 12)
  ),
  cells = dict(
    values = [df.Color, df.Year],
    line = dict(color = [df.Color]),
    fill = dict(color = [df.Color]),
    align = 'center',
    font = dict(color = 'black', size = 11)
    ))

data = [trace0]

py.iplot(data, filename = "row variable color")<jupyter_output><empty_output><jupyter_text>Cell Color Based on Variable<jupyter_code>import plotly.plotly as py
import plotly.graph_objs as go

import numpy as np
import colorlover as cl

colors = cl.scales['9']['seq']['Reds']
a = np.random.randint(low=0, high=9, size=10)
b = np.random.randint(low=0, high=9, size=10)
c = np.random.randint(low=0, high=9, size=10)


trace0 = go.Table(
  header = dict(
    values = ['<b>Column A</b>', '<b>Column B</b>', '<b>Column C</b>'],
    line = dict(color = 'white'),
    fill = dict(color = 'white'),
    align = 'center',
    font = dict(color = 'black', size = 12)
  ),
  cells = dict(
    values = [a,b,c],
    line = dict(color = [np.array(colors)[a],np.array(colors)[b],
                        np.array(colors)[c]]),
    fill = dict(color = [np.array(colors)[a],np.array(colors)[b],
                        np.array(colors)[c]]),
    align = 'center',
    font = dict(color = 'white', size = 11)
    ))

data = [trace0]

py.iplot(data, filename = "cell variable color")<jupyter_output><empty_output><jupyter_text>Dash Example<jupyter_code>from IPython.display import IFrame
IFrame(src= "https://dash-simple-apps.plotly.host/dash-tableplot/", width="100%", height="850px", frameBorder="0")<jupyter_output><empty_output><jupyter_text>Find the dash app source code [here]("https://github.com/plotly/simple-example-chart-apps/tree/master/table")  ReferenceFor more information on tables and table attributes see: https://plot.ly/python/reference/table.<jupyter_code>from IPython.display import display, HTML

display(HTML('<link href="//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Inconsolata|Ubuntu+Mono:400,700" rel="stylesheet" type="text/css" />'))
display(HTML('<link rel="stylesheet" type="text/css" href="http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css">'))

! pip install git+https://github.com/plotly/publisher.git --upgrade
import publisher
publisher.publish(
    'table.ipynb', 'python/table/', 'Python Tables | plotly',
    'How to make tables in Python with Plotly.',
    title = 'Tables | plotly',
    name = 'Tables',
    thumbnail='thumbnail/table.gif', language='python',
    has_thumbnail='true', display_as='basic', order=7,
    ipynb='~notebook_demo/197')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15992886781268523, 'fraction_numerical': 0.03935981031416716, 'mean_word_length': 3.823327615780446, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 71, 'https://': 11, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '418274', 'license': 'CC-BY-3.0', 'n_tokens_mistral': 3257, 'n_tokens_neox': 2955, 'n_words': 705, 'path': '_posts/python/basic/table/table.ipynb', 'repo_name': 'ayulockin/documentation', 'size': '8435'}