Skip to main content
In this example, we’ll use DocParse to extract a cash flow table (shown below) from the 10-K financial document of 3M, and turn it into a pandas dataframe.

Extracting Table Cell from DocParse

table_demo.py
If you inspect the partitioned_file variable, you’ll notice that it’s a large JSON object with details about all the components in the PDF (check out this page to understand the schema of the returned JSON object in detail). Below, we highlight the table element that contains the information about the table in the page.
output.json
In particular let’s look at the cells field which is an array of cell objects that represent each of the cells in the table. Let’s focus on the first element of that list.
cells.json

Displaying the Table

Here we’ve detected the first cell, its bounding box (which indicates the coordinates of the cell in the PDF.), whether it’s a header cell and its contents. You can then process this JSON however you’d like for further analysis. In the notebook we use the tables_to_pandas function to turn the JSON into a pandas dataframe and then perform some analysis on it:
display_table.py
The output is given below: