.create_table()
Anonymous contributor
Published Feb 20, 2025
Contribute to Docs
.create_table()
is a function in Plotly’s figure_factory
module. It accepts data in the form of a list of lists or a Pandas DataFrame and returns a Plotly Figure
object representing the table.
Syntax
plotly.figure_factory.create_table(table_text, index=False, font_colors=None, index_title='', **kwargs)
table_text
(list of lists or Pandas DataFrame): The table data to be displayed. If using a Pandas DataFrame, the table will automatically extract its values.index
(bool): Whether to include an index column when using a Pandas DataFrame or use the first element of each inner list as an index when passing a list of lists. Default value isFalse
.font_colors
(list, optional): Specifies the font colors for the table text. It can be a single color for all text or a list defining colors for rows. Default is[#000000]
(black text).index_title
(str, optional): Sets the title for the index column ifindex=True
. Default is an empty string.**kwargs
: Additional keyword arguments passed to plotly.graph_objects.Heatmap for further customization.
Example
The following example showcases the use of the .create_table()
function:
import plotly.figure_factory as ffimport pandas as pd# Sample datadata = pd.DataFrame({"Name": ["Luke", "Anakin", "Padme", "Yoda"],"Age": [25, 50, 45, 353],"Planet": ["Tatooine", "Tatooine", "Naboo", "Dagobah"]})# Create a tablefig = ff.create_table(data)# Show the figurefig.show()
The code above produces the following output:
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python:Plotly on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Course
Learn Python 3
Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.With CertificateBeginner Friendly23 hours