# PyArrow Tables


# In-Memory Arrow Table

`tbl_preview()` also accepts a `pyarrow.Table` directly -- no file needed.


``` python
import pyarrow as pa
from great_docs import tbl_preview

tbl = pa.table({
    'city': ['Tokyo', 'Delhi', 'Shanghai', 'São Paulo', 'Mexico City',
             'Cairo', 'Mumbai', 'Beijing', 'Dhaka', 'Osaka'],
    'country': ['Japan', 'India', 'China', 'Brazil', 'Mexico',
                'Egypt', 'India', 'China', 'Bangladesh', 'Japan'],
    'population_m': [13.96, 11.03, 24.87, 12.33, 9.21,
                     9.54, 12.44, 21.54, 8.91, 2.75],
    'area_km2': [2194, 1484, 6341, 1521, 1485,
                 3085, 603, 16411, 306, 225],
})

tbl_preview(tbl, show_all=True)
```


<table class="gt_table" data-quarto-disable-processing="true" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading">
<th colspan="5" class="gt_heading gt_title gt_font_normal"><div style="padding-top: 0; padding-bottom: 7px;">
<span class="gd-tbl-badge" style="background-color: #E8EAF6; color: #283593; border: 1px solid #E8EAF6; margin-right: 8px;">Arrow</span>Rows10Columns4
</div></th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_right" scope="col"></th>
<th id="city" class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"><div>

city

<em>str</em>

</div></th>
<th id="country" class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"><div>

country

<em>str</em>

</div></th>
<th id="population_m" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col"><div>

population_m

<em>f64</em>

</div></th>
<th id="area_km2" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col"><div>

area_km2

<em>i64</em>

</div></th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<td class="gt_row gt_right gd-tbl-rownum">0</td>
<td class="gt_row gt_left" style="max-width: 118px">Tokyo</td>
<td class="gt_row gt_left" style="max-width: 111px">Japan</td>
<td class="gt_row gt_right" style="max-width: 133px">13.96</td>
<td class="gt_row gt_right" style="max-width: 101px">2194</td>
</tr>
<tr>
<td class="gt_row gt_right gd-tbl-rownum">1</td>
<td class="gt_row gt_left" style="max-width: 118px">Delhi</td>
<td class="gt_row gt_left" style="max-width: 111px">India</td>
<td class="gt_row gt_right" style="max-width: 133px">11.03</td>
<td class="gt_row gt_right" style="max-width: 101px">1484</td>
</tr>
<tr>
<td class="gt_row gt_right gd-tbl-rownum">2</td>
<td class="gt_row gt_left" style="max-width: 118px">Shanghai</td>
<td class="gt_row gt_left" style="max-width: 111px">China</td>
<td class="gt_row gt_right" style="max-width: 133px">24.87</td>
<td class="gt_row gt_right" style="max-width: 101px">6341</td>
</tr>
<tr>
<td class="gt_row gt_right gd-tbl-rownum">3</td>
<td class="gt_row gt_left" style="max-width: 118px">São Paulo</td>
<td class="gt_row gt_left" style="max-width: 111px">Brazil</td>
<td class="gt_row gt_right" style="max-width: 133px">12.33</td>
<td class="gt_row gt_right" style="max-width: 101px">1521</td>
</tr>
<tr>
<td class="gt_row gt_right gd-tbl-rownum">4</td>
<td class="gt_row gt_left" style="max-width: 118px">Mexico City</td>
<td class="gt_row gt_left" style="max-width: 111px">Mexico</td>
<td class="gt_row gt_right" style="max-width: 133px">9.21</td>
<td class="gt_row gt_right" style="max-width: 101px">1485</td>
</tr>
<tr>
<td class="gt_row gt_right gd-tbl-rownum">5</td>
<td class="gt_row gt_left" style="max-width: 118px">Cairo</td>
<td class="gt_row gt_left" style="max-width: 111px">Egypt</td>
<td class="gt_row gt_right" style="max-width: 133px">9.54</td>
<td class="gt_row gt_right" style="max-width: 101px">3085</td>
</tr>
<tr>
<td class="gt_row gt_right gd-tbl-rownum">6</td>
<td class="gt_row gt_left" style="max-width: 118px">Mumbai</td>
<td class="gt_row gt_left" style="max-width: 111px">India</td>
<td class="gt_row gt_right" style="max-width: 133px">12.44</td>
<td class="gt_row gt_right" style="max-width: 101px">603</td>
</tr>
<tr>
<td class="gt_row gt_right gd-tbl-rownum">7</td>
<td class="gt_row gt_left" style="max-width: 118px">Beijing</td>
<td class="gt_row gt_left" style="max-width: 111px">China</td>
<td class="gt_row gt_right" style="max-width: 133px">21.54</td>
<td class="gt_row gt_right" style="max-width: 101px">16411</td>
</tr>
<tr>
<td class="gt_row gt_right gd-tbl-rownum">8</td>
<td class="gt_row gt_left" style="max-width: 118px">Dhaka</td>
<td class="gt_row gt_left" style="max-width: 111px">Bangladesh</td>
<td class="gt_row gt_right" style="max-width: 133px">8.91</td>
<td class="gt_row gt_right" style="max-width: 101px">306</td>
</tr>
<tr>
<td class="gt_row gt_right gd-tbl-rownum">9</td>
<td class="gt_row gt_left" style="max-width: 118px">Osaka</td>
<td class="gt_row gt_left" style="max-width: 111px">Japan</td>
<td class="gt_row gt_right" style="max-width: 133px">2.75</td>
<td class="gt_row gt_right" style="max-width: 101px">225</td>
</tr>
</tbody>
</table>


# Arrow Table with Typed Columns

PyArrow preserves rich type information -- booleans, dates, decimals -- which `tbl_preview()` maps to short dtype labels.


``` python
import pyarrow as pa
from datetime import date

tbl = pa.table({
    'event': ['Launch', 'Update', 'Hotfix', 'Deprecation'],
    'date': [date(2025, 1, 15), date(2025, 3, 1), date(2025, 3, 12), date(2025, 6, 30)],
    'critical': [True, False, True, False],
    'affected_users': [50000, 12000, 8500, 2000],
})

tbl_preview(tbl, show_all=True)
```


<table class="gt_table" data-quarto-disable-processing="true" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading">
<th colspan="5" class="gt_heading gt_title gt_font_normal"><div style="padding-top: 0; padding-bottom: 7px;">
<span class="gd-tbl-badge" style="background-color: #E8EAF6; color: #283593; border: 1px solid #E8EAF6; margin-right: 8px;">Arrow</span>Rows4Columns4
</div></th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_right" scope="col"></th>
<th id="event" class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"><div>

event

<em>str</em>

</div></th>
<th id="date" class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"><div>

date

<em>date</em>

</div></th>
<th id="critical" class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"><div>

critical

<em>bool</em>

</div></th>
<th id="affected_users" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col"><div>

affected_users

<em>i64</em>

</div></th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<td class="gt_row gt_right gd-tbl-rownum">0</td>
<td class="gt_row gt_left" style="max-width: 114px">Launch</td>
<td class="gt_row gt_left" style="max-width: 107px">2025-01-15</td>
<td class="gt_row gt_left" style="max-width: 97px">True</td>
<td class="gt_row gt_right" style="max-width: 144px">50000</td>
</tr>
<tr>
<td class="gt_row gt_right gd-tbl-rownum">1</td>
<td class="gt_row gt_left" style="max-width: 114px">Update</td>
<td class="gt_row gt_left" style="max-width: 107px">2025-03-01</td>
<td class="gt_row gt_left" style="max-width: 97px">False</td>
<td class="gt_row gt_right" style="max-width: 144px">12000</td>
</tr>
<tr>
<td class="gt_row gt_right gd-tbl-rownum">2</td>
<td class="gt_row gt_left" style="max-width: 114px">Hotfix</td>
<td class="gt_row gt_left" style="max-width: 107px">2025-03-12</td>
<td class="gt_row gt_left" style="max-width: 97px">True</td>
<td class="gt_row gt_right" style="max-width: 144px">8500</td>
</tr>
<tr>
<td class="gt_row gt_right gd-tbl-rownum">3</td>
<td class="gt_row gt_left" style="max-width: 114px">Deprecation</td>
<td class="gt_row gt_left" style="max-width: 107px">2025-06-30</td>
<td class="gt_row gt_left" style="max-width: 97px">False</td>
<td class="gt_row gt_right" style="max-width: 144px">2000</td>
</tr>
</tbody>
</table>
