Skip to content

TST: Adding test to concat where copy=False for ExtensionArrays #30625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 4, 2020
Merged
Changes from 1 commit
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
22 changes: 22 additions & 0 deletions pandas/tests/reshape/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2730,3 +2730,25 @@ def test_concat_datetimeindex_freq():
expected = pd.DataFrame(data[50:] + data[:50], index=dr[50:].append(dr[:50]))
expected.index._data.freq = None
tm.assert_frame_equal(result, expected)


def test_concat_copy_false_extension_array():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be add to the class at pandas.tests.extension.base.reshaping.BaseReshapingTests.

It'll need to be restructured a bit to not refer to decimal specifically. It needs to work with the data provided by the fixture. See the other concat there for examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM. Moved the test to pandas.tests.extension.base.reshaping.BaseReshapingTests and updated the test to use the data provided by the fixture. I also simplified the test to make it more clear.

# GH 20756
range_arr = list(range(8))
dec_arr = to_decimal(range_arr)
df1 = pd.DataFrame({"int1": [1, 2, 3], "key1": [0, 1, 2], "ext1": dec_arr[:3]})
df2 = pd.DataFrame(
{"int2": [1, 2, 3, 4], "key2": [0, 0, 1, 3], "ext2": dec_arr[3:7]}
)
expected = pd.DataFrame(
{
"int1": [1, 2, 3, float("nan")],
"key1": [0, 1, 2, float("nan")],
"ext1": to_decimal(range_arr[:3] + ["nan"]),
"int2": [1, 2, 3, 4],
"key2": [0, 0, 1, 3],
"ext2": dec_arr[3:7],
}
)
result = pd.concat([df1, df2], axis=1, copy=False)
tm.assert_frame_equal(result, expected)