fn _repr_html_()

in src/dataframe.rs [237:270]


    fn _repr_html_(&self, py: Python) -> PyDataFusionResult<String> {
        // Get the Python formatter and config
        let PythonFormatter { formatter, config } = get_python_formatter_with_config(py)?;
        let (batches, has_more) = wait_for_future(
            py,
            collect_record_batches_to_display(self.df.as_ref().clone(), config),
        )?;
        if batches.is_empty() {
            // This should not be reached, but do it for safety since we index into the vector below
            return Ok("No data to display".to_string());
        }

        let table_uuid = uuid::Uuid::new_v4().to_string();

        // Convert record batches to PyObject list
        let py_batches = batches
            .into_iter()
            .map(|rb| rb.to_pyarrow(py))
            .collect::<PyResult<Vec<PyObject>>>()?;

        let py_schema = self.schema().into_pyobject(py)?;

        let kwargs = pyo3::types::PyDict::new(py);
        let py_batches_list = PyList::new(py, py_batches.as_slice())?;
        kwargs.set_item("batches", py_batches_list)?;
        kwargs.set_item("schema", py_schema)?;
        kwargs.set_item("has_more", has_more)?;
        kwargs.set_item("table_uuid", table_uuid)?;

        let html_result = formatter.call_method("format_html", (), Some(&kwargs))?;
        let html_str: String = html_result.extract()?;

        Ok(html_str)
    }