Skip to main content

Example Usage

import zero_true as zt
import pandas as pd

# Sample data
data = {
  'Name': ['Alice', 'Bob', 'Charlie'],
  'Age': [24, 30, 22],
  'City': ['New York', 'Los Angeles', 'Chicago']
}

# Create a pandas DataFrame
df = pd.DataFrame(data)

# Create the headers for the DataFrame component
headers = [
  zt.Header(key='Name', title='Name', align='start'),
  zt.Header(key='Age', title='Age', align='start'),
  zt.Header(key='City', title='City', align='start')
]

# Create the DataFrame component from the pandas DataFrame
sample_dataframe = zt.DataFrame.from_dataframe(df, id='sample_dataframe')

# Update headers (if needed)
sample_dataframe.headers = headers

# Assuming you have a mechanism to render or use this DataFrame within a layout
layout = zt.Layout(components=[sample_dataframe])

Example Output

Overview

pydantic model zero_true.DataFrame The DataFrame component utilizes the familiar structure of a data table, making it easy to integrate and display data from various sources, including directly from a pandas DataFrame.
This component is essential for applications that require data analysis and presentation, providing functionalities like sorting, filtering, and viewing detailed information in a user-friendly manner.

JSON Schema

{
   "title": "DataFrame",
   "description": "DataFrame component for displaying tabluar data",
   "type": "object",
   "properties": {
      "id": {
         "description": "Unique id for a component",
         "title": "Id",
         "type": "string"
      },
      "variable_name": {
         "default": "",
         "description": "Optional variable name associated with a component",
         "title": "Variable Name",
         "type": "string"
      },
      "component": {
         "default": "v-data-table",
         "description": "Vue component name.",
         "title": "Component",
         "type": "string"
      },
      "headers": {
         "default": [],
         "description": "List of column headers for the DataFrame",
         "items": {
            "$ref": "#/$defs/Header"
         },
         "title": "Headers",
         "type": "array"
      },
      "items": {
         "default": [],
         "description": "List of items to be displayed in the DataFrame",
         "items": {
            "type": "object"
         },
         "title": "Items",
         "type": "array"
      }
   },
   "$defs": {
      "Header": {
         "description": "Header class for the columns of a DataFrame component",
         "properties": {
            "title": {
               "default": "",
               "description": "Title of the column",
               "title": "Title",
               "type": "string"
            },
            "align": {
               "default": "start",
               "description": "Alignment of values in the column",
               "title": "Align",
               "type": "string"
            },
            "key": {
               "default": "name",
               "description": "Key of the column, must match the key in the items list",
               "title": "Key",
               "type": "string"
            }
         },
         "title": "Header",
         "type": "object"
      }
   },
   "required": [
      "id"
   ]
}

Bellow are the various attributes you can assign to the component. Utlizing them can allow for modifications to the pre-created object.
zero_true.DataFrame
Zero True Component
I