Skip to content

Commit bab5572

Browse files
authored
Update test_parquet.py I added test method for parquet stringdtype
1 parent 522ed7f commit bab5572

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pandas/tests/io/test_parquet.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,26 @@ def test_basic_subset_columns(self, pa, df_full):
718718
expected=df[["string", "int"]],
719719
read_kwargs={"columns": ["string", "int"]},
720720
)
721+
#ekleme yapılan yeni yer***
722+
@pytest.mark.parametrize("string_storage", ["pyarrow", "python"])
723+
def test_parquet_stringdtype_roundtrip(self, tmp_path, pa):
724+
import pandas as pd
725+
from pandas.testing import assert_frame_equal
726+
727+
df = pd.DataFrame({
728+
"a": pd.Series(["x", "y", "z"], dtype=pd.StringDtype(storage=string_storage))
729+
})
730+
731+
file_path = tmp_path / "stringdtype.parquet"
732+
df.to_parquet(file_path, engine="pyarrow")
733+
734+
result = pd.read_parquet(file_path, engine="pyarrow")
735+
736+
expected_dtype = pd.StringDtype(storage=string_storage)
737+
assert result["a"].dtype == expected_dtype, f"Dtype mismatch: got {result['a'].dtype}, expected {expected_dtype}"
738+
739+
assert_frame_equal(result, df)
740+
721741

722742
def test_to_bytes_without_path_or_buf_provided(self, pa, df_full):
723743
# GH 37105

0 commit comments

Comments
 (0)