mirror of
https://github.com/DS4SD/docling.git
synced 2025-12-08 12:48:28 +00:00
docs(examples): remove deprecation warnings with export_to_dataframe (#2638)
fix: remove deprecation warnings with export_to_dataframe Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
This commit is contained in:
committed by
GitHub
parent
d6ddf9f4cb
commit
f5528623a7
2
docs/examples/export_tables.py
vendored
2
docs/examples/export_tables.py
vendored
@@ -52,7 +52,7 @@ def main():
|
|||||||
|
|
||||||
# Export tables
|
# Export tables
|
||||||
for table_ix, table in enumerate(conv_res.document.tables):
|
for table_ix, table in enumerate(conv_res.document.tables):
|
||||||
table_df: pd.DataFrame = table.export_to_dataframe()
|
table_df: pd.DataFrame = table.export_to_dataframe(doc=conv_res.document)
|
||||||
print(f"## Table {table_ix}")
|
print(f"## Table {table_ix}")
|
||||||
print(table_df.to_markdown())
|
print(table_df.to_markdown())
|
||||||
|
|
||||||
|
|||||||
5
docs/v2.md
vendored
5
docs/v2.md
vendored
@@ -146,6 +146,9 @@ is now available in conversion results as a `DoclingDocument` object.
|
|||||||
`DoclingDocument` provides a neat set of APIs to construct, iterate and export content in the document, as shown below.
|
`DoclingDocument` provides a neat set of APIs to construct, iterate and export content in the document, as shown below.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
import pandas as pd
|
||||||
|
from docling_core.types.doc import TextItem, TableItem
|
||||||
|
|
||||||
conv_result: ConversionResult = doc_converter.convert("https://arxiv.org/pdf/2408.09869") # previously `convert_single`
|
conv_result: ConversionResult = doc_converter.convert("https://arxiv.org/pdf/2408.09869") # previously `convert_single`
|
||||||
|
|
||||||
## Inspect the converted document:
|
## Inspect the converted document:
|
||||||
@@ -156,7 +159,7 @@ for item, level in conv_result.document.iterate_items():
|
|||||||
if isinstance(item, TextItem):
|
if isinstance(item, TextItem):
|
||||||
print(item.text)
|
print(item.text)
|
||||||
elif isinstance(item, TableItem):
|
elif isinstance(item, TableItem):
|
||||||
table_df: pd.DataFrame = item.export_to_dataframe()
|
table_df: pd.DataFrame = item.export_to_dataframe(doc=conv_result.document)
|
||||||
print(table_df.to_markdown())
|
print(table_df.to_markdown())
|
||||||
elif ...:
|
elif ...:
|
||||||
#...
|
#...
|
||||||
|
|||||||
@@ -171,9 +171,6 @@ def verify_table_v2(true_item: TableItem, pred_item: TableItem, fuzzy: bool):
|
|||||||
assert true_item.data is not None, "documents are expected to have table data"
|
assert true_item.data is not None, "documents are expected to have table data"
|
||||||
assert pred_item.data is not None, "documents are expected to have table data"
|
assert pred_item.data is not None, "documents are expected to have table data"
|
||||||
|
|
||||||
# print("True: \n", true_item.export_to_dataframe().to_markdown())
|
|
||||||
# print("Pred: \n", true_item.export_to_dataframe().to_markdown())
|
|
||||||
|
|
||||||
for i, row in enumerate(true_item.data.grid):
|
for i, row in enumerate(true_item.data.grid):
|
||||||
for j, col in enumerate(true_item.data.grid[i]):
|
for j, col in enumerate(true_item.data.grid[i]):
|
||||||
# print("true: ", true_item.data[i][j].text)
|
# print("true: ", true_item.data[i][j].text)
|
||||||
|
|||||||
Reference in New Issue
Block a user