Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion modin/core/dataframe/pandas/dataframe/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ def __init__(
self._row_lengths_cache = row_lengths
self._column_widths_cache = column_widths
self._pandas_backend = pandas_backend
if pandas_backend != "pyarrow":
if pandas_backend != "pyarrow" or len(partitions) == 0:
# If the backend is pyarrow and there are no partitions, the computed dtype otherwise becomes NaN,
# which means we lost the dtype, so actually set it in that case
self.set_dtypes_cache(dtypes)
else:
# In this case, the type precomputation may be incorrect; we need
Expand Down
7 changes: 7 additions & 0 deletions modin/tests/pandas/dataframe/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import numpy as np
import pandas
import pandas._libs.lib as lib
import pyarrow as pa
import pytest
from numpy.testing import assert_array_equal

Expand Down Expand Up @@ -1533,3 +1534,9 @@ def test_series_does_not_warn_distributing_takes_time():
with warnings.catch_warnings():
warnings.filterwarnings("error", regex, UserWarning)
pd.Series(np.random.randint(1_000_000, size=(2_400_000)))


@pytest.mark.parametrize("dtype", [np.int64, pd.ArrowDtype(pa.int64())])
def test_empty_df_dtypes(dtype):
df = pd.DataFrame({"A": []}, dtype=dtype)
assert df.dtypes["A"] == dtype
Loading