Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add pyarrow.Table support #487

Merged
merged 16 commits into from
Nov 25, 2024
9 changes: 7 additions & 2 deletions great_tables/_gt_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
copy_data,
create_empty_frame,
get_column_names,
_get_column_dtype,
n_rows,
to_list,
validate_frame,
Expand Down Expand Up @@ -175,7 +176,11 @@ def render_formats(self, data_tbl: TblData, formats: list[FormatInfo], context:
# TODO: I think that this is very inefficient with polars, so
# we could either accumulate results and set them per column, or
# could always use a pandas DataFrame inside Body?
_set_cell(self.body, row, col, result)
new_body = _set_cell(self.body, row, col, result)
if new_body is not None:
# Some backends do not support inplace operations, but return a new dataframe
# TODO: Consolidate the behaviour of _set_cell
self.body = new_body

return self

Expand Down Expand Up @@ -335,7 +340,7 @@ def align_from_data(self, data: TblData) -> Self:
# a Pandas DataFrame or a Polars DataFrame
col_classes = []
for col in get_column_names(data):
dtype = data[col].dtype
dtype = _get_column_dtype(data, col)

if dtype == "object":
# Check whether all values in 'object' columns are strings that
Expand Down
Loading