Skip to content

Commit 1d4cd7f

Browse files
Sai Sandeep RamavathSai Sandeep Ramavath
authored andcommitted
Added integration testcase
1 parent cb40e31 commit 1d4cd7f

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

pandas/tests/test_integration.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
"""
2+
Integration tests for pandas modules.
3+
4+
These tests verify interactions between multiple modules/components:
5+
- pandas.core.series (Series construction)
6+
- pandas.core.frame (DataFrame construction)
7+
- pandas.core.dtypes (dtype handling)
8+
9+
"""
10+
import numpy as np
11+
import pytest
12+
13+
import pandas as pd
14+
from pandas import Series, DataFrame, Index
15+
from pandas.core.missing import clean_fill_method
16+
from pandas._libs import lib
17+
from pandas.util._validators import (
18+
validate_args_and_kwargs,
19+
validate_fillna_kwargs,
20+
check_dtype_backend,
21+
validate_percentile,
22+
)
23+
24+
25+
class TestSandeepIntegration:
26+
"""Integration tests by Sandeep Ramavath covering Series-DataFrame-dtype interactions."""
27+
28+
def test_series_to_dataframe_dtype_preservation(self):
29+
"""Test Series.to_frame() preserves dtype through internals conversion.
30+
31+
This exercises interaction between:
32+
- pandas.core.series.Series.to_frame()
33+
- pandas.core.internals (manager conversion)
34+
- pandas.core.frame.DataFrame
35+
- pandas.core.dtypes (dtype preservation)
36+
"""
37+
# Create Series with specific dtype
38+
s = Series([1, 2, 3], name="test_col", dtype="int32")
39+
40+
# Convert to DataFrame - should preserve dtype through internal conversion
41+
df = s.to_frame()
42+
43+
assert isinstance(df, DataFrame)
44+
assert df.columns[0] == "test_col"
45+
assert df["test_col"].dtype == np.dtype("int32")
46+
assert len(df) == 3
47+
assert (df["test_col"] == s).all()
48+
49+
def test_dataframe_from_dict_mixed_series_dtypes(self):
50+
"""Test DataFrame construction from dict with mixed Series dtypes.
51+
52+
This exercises interaction between:
53+
- pandas.core.frame.DataFrame.__init__
54+
- pandas.core.internals.construction.dict_to_mgr
55+
- pandas.core.series.Series (multiple instances with different dtypes)
56+
- pandas.core.dtypes (type coercion and preservation)
57+
"""
58+
# Create Series with different dtypes
59+
s1 = Series([1, 2, 3], dtype="int64")
60+
s2 = Series([1.0, 2.0, 3.0], dtype="float32")
61+
s3 = Series(["a", "b", "c"], dtype="object")
62+
63+
# Build DataFrame from dict of Series
64+
df = DataFrame({"col1": s1, "col2": s2, "col3": s3})
65+
66+
# Verify each column maintains its original dtype
67+
assert df["col1"].dtype == np.dtype("int64")
68+
assert df["col2"].dtype == np.dtype("float32")
69+
assert df["col3"].dtype == np.dtype("object")
70+
assert len(df) == 3
71+
72+

0 commit comments

Comments
 (0)