
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Gviz Data Table is a simple Python library for converting Python data types to the Google Visualization Data Table JSON format. https://developers.google.com/chart/interactive/docs/reference
The Google Visualization Library itself is a Javascript library that provides interactive charts that work in pretty much any browser. The libraries cover most use cases including tables, as well as charts, so you can have a chart and a table of the same data.
Gviz Data Table is designed primarily for use with data sources such as databases. Usage is supposed to be minimal: you provide a schema, that is a list of columns, and the rows of data. A column must have a name and Python data type. It can also have a label which will be used for display, otherwise the name will be used.
Each row is a sequence of cells. Although columns are explicit row names are
always the first cell in a row. Like columns, cells can also have labels.
Gviz Data Table will validate each cell to make sure that data conforms to
type specified in the schema and will map Python types to their JSON
equivalent but it does not coerce any data, i.e. if a column has type int
and a cell's data is a string containing numerical characters only this will
still raise an exception.
Gviz Data Table handles data conversion only. You will need to add the necessary Javascript to an web page in order for any charts or table to be drawn. Tables, columns and cells can all have options which are just dictionaries. As there is no further definition of options no validation of their items occurs. Unknown items will simply be ignored.
Gviz Data Table is composed of: one container class Table
; two data
classes, Cell
and Column
and one JSON encoder. Application code should
probably only ever need to use Table and the encoder.
Tables can be initialised with a schema or these can be added imperatively. Once one row has been added to a table no more columns can be added. Once all the rows have been added. The table can be converted into JSON using the encoder.
Example
Let's say we have data representing the names and salaries of people
====== ====== Name Salary ====== ====== Jim 50 Bob 80 ====== ======
This could be coded in Gviz Data Table like this:
.. code-block:: python
from gviz_data_table import Table
table = Table()
table.add_column('name', str, "Name")
table.add_column('salary', int, "Salary")
table.append(["Jim", 50])
table.append(["Bob", 80])
This can be encoded into JSON using the encoder:
.. code-block:: python
from gviz_data_table import encode
encode(table)
It can also be directly encoded
.. code-block:: python
table.encode()
And also used as a static data source for asynchronous loading from Javascript
.. code-block:: python
table.source()
FAQs
Python API for Google Visualization
We found that gviz-data-table demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.