dweih commented on issue #47022: URL: https://github.com/apache/arrow/issues/47022#issuecomment-3054365904
Sorry! Typo, I was trying something else and must have copied from the wrong place... ``` import polars as pl import pyarrow as pa n = 100 cat_values = [f"cat_{i}" for i in range(n)] df = pl.DataFrame({ "cat": cat_values, "val": list(range(n)) }) arrow_table = df.to_arrow() dict_type = pa.dictionary(index_type=pa.uint16(), value_type=pa.string()) arrow_table = arrow_table.set_column( arrow_table.schema.get_field_index("cat"), "cat", arrow_table.column("cat").cast(dict_type) ) print("Arrow schema:", arrow_table.schema) try: pdf = arrow_table.to_pandas() print("Loaded into pandas successfully.") except Exception as e: print("Failed to load into pandas:") print(e) try: pol_df = pl.from_arrow(arrow_table) print("Loaded into Polars successfully.") except Exception as e: print("Failed to load into Polars:") print(e) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org