AlenkaF commented on a change in pull request #12311: URL: https://github.com/apache/arrow/pull/12311#discussion_r800594948
########## File path: python/pyarrow/table.pxi ########## @@ -1779,15 +1796,41 @@ cdef class Table(_PandasConvertible): <pyarrow.lib.Table object at 0x7f05d1fb1b40> """ from pyarrow.pandas_compat import dataframe_to_arrays - arrays, schema = dataframe_to_arrays( + arrays, schema, n_rows = dataframe_to_arrays( df, schema=schema, preserve_index=preserve_index, nthreads=nthreads, columns=columns, safe=safe ) - return cls.from_arrays(arrays, schema=schema) + + cdef: + vector[shared_ptr[CChunkedArray]] arr + shared_ptr[CSchema] c_schema + # If df is empty but row index is not, create empty Table with rows >0 + if n_rows: + names = None + metadata = None + converted_arrays = _sanitize_arrays(arrays, names, schema, metadata, + &c_schema) + arr.reserve(0) + for item in converted_arrays: + if isinstance(item, Array): + arr.push_back( + make_shared[CChunkedArray]( + (<Array> item).sp_array + ) + ) + elif isinstance(item, ChunkedArray): + arr.push_back((<ChunkedArray> item).sp_chunked_array) + else: + raise TypeError(type(item)) Review comment: I wasn't able to build without cython erroring if I didn't use this whole part - but definitely agree, it should be simplified somehow. I'll try what you are proposing, thanks! -- 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