Skip to content
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

[REVIEW] Concatenate an empty and non-empty series #6157

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
19f5174
Merge pull request #4714 from rapidsai/branch-0.13
raydouglass Mar 30, 2020
a2804c3
REL v0.13.0 release
GPUtester Mar 31, 2020
fef2a2b
REL v0.13.0 CHANGELOG Updates
mike-wendt Apr 1, 2020
ab00eb0
Merge pull request #5310 from rapidsai/branch-0.14
raydouglass Jun 3, 2020
b34b838
REL v0.14.0 release
GPUtester Jun 3, 2020
b1dd9a5
updated concat function to allow concating an empty series with a non…
marlenezw Sep 4, 2020
4f9d1ea
updated changelog.md
marlenezw Sep 4, 2020
45db07b
Update CHANGELOG.md
galipremsagar Sep 4, 2020
124d53a
Merge branch 'branch-0.16' into feature/concat_empty_and_non_empty_se…
galipremsagar Sep 4, 2020
53a29bb
made some changes to allow an empty and non-empty series to conconcat…
marlenezw Sep 8, 2020
2326419
changes to be merged from origin
marlenezw Sep 8, 2020
77d0d0e
changes to reshape
marlenezw Sep 8, 2020
81e74d9
Merge branch 'feature/concat_empty_and_non_empty_series' of https://g…
marlenezw Sep 8, 2020
d63cb49
allowed for dtype check
marlenezw Sep 9, 2020
b8e728c
updated concat function to allow concating an empty series with a non…
marlenezw Sep 4, 2020
e088327
updated changelog.md
marlenezw Sep 4, 2020
e72e198
made some changes to allow an empty and non-empty series to conconcat…
marlenezw Sep 8, 2020
01c0901
updtaes to docstring to resolve merge conflict
marlenezw Sep 9, 2020
9c62595
resolve merge conflicts in docs
marlenezw Sep 9, 2020
4d9b95f
changes to reshape
marlenezw Sep 8, 2020
b6ec5a0
Update CHANGELOG.md
galipremsagar Sep 4, 2020
a1532dc
first changes to acos method.
marlenezw Sep 9, 2020
13536cb
resolving merge conflicts
marlenezw Sep 9, 2020
4f501af
updating chanelog.md
marlenezw Sep 9, 2020
ecad0f2
chanelog.md conflict resolution
marlenezw Sep 9, 2020
cff6904
changes to chanelog.md
marlenezw Sep 10, 2020
979f8a8
Update CHANGELOG.md
galipremsagar Sep 4, 2020
f0d4f40
updating chanelog.md
marlenezw Sep 9, 2020
d54d598
chanelog.md conflict resolution
marlenezw Sep 9, 2020
c21411c
resolving merge conflicts in conf.py
marlenezw Sep 10, 2020
b7eb697
Delete conf.py
marlenezw Sep 10, 2020
7efd0f4
updated chanelog.md
marlenezw Sep 10, 2020
21d2544
Merge branch 'branch-0.16' into feature/concat_empty_and_non_empty_se…
marlenezw Sep 10, 2020
dc08506
final changes to changelog.md
marlenezw Sep 10, 2020
2378d9d
fixing style issues in reshape.py
marlenezw Sep 10, 2020
f586461
removing earlier changes to frame.py, these changes are for another PR.
marlenezw Sep 10, 2020
58f2293
conf.py
marlenezw Sep 11, 2020
550061c
Merge branch 'branch-0.16' of https://github.com/rapidsai/cudf into f…
marlenezw Sep 11, 2020
ca5a02b
test for concat empty and non-empty series.
marlenezw Sep 11, 2020
4445878
fixing style issues
marlenezw Sep 11, 2020
6344882
Merge branch 'branch-0.16' of https://github.com/rapidsai/cudf into f…
marlenezw Sep 11, 2020
22f7340
Update python/cudf/cudf/core/reshape.py
marlenezw Sep 14, 2020
210b40b
Merge branch 'branch-0.16' of https://github.com/rapidsai/cudf into f…
marlenezw Sep 14, 2020
afaaa4a
changelog.md changes
marlenezw Sep 14, 2020
77b05ec
Merge branch 'feature/concat_empty_and_non_empty_series' of https://g…
marlenezw Sep 14, 2020
6753b8d
fixing style issues.
marlenezw Sep 14, 2020
774056d
conf file style issues fixed
marlenezw Sep 14, 2020
1100886
updates from upstream.
marlenezw Sep 14, 2020
01c99c2
Merge branch 'branch-0.16' of https://github.com/rapidsai/cudf into f…
marlenezw Sep 15, 2020
fe43053
added test for concat two empty series.
marlenezw Sep 15, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
- PR #6199 Fix index preservation for dask_cudf parquet
- PR #6207 Remove shared libs from Java sources jar
- PR #6212 Update codeowners file
- PR #6157 Fix issue related to `Series.concat` to concat a non-empty and empty series.
galipremsagar marked this conversation as resolved.
Show resolved Hide resolved
- PR #6226 Add in some JNI checks for null handles


Expand Down
14 changes: 10 additions & 4 deletions python/cudf/cudf/core/reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def concat(objs, axis=0, ignore_index=False, sort=None):

df.columns = result_columns.unique()
if ignore_index:
df.index = None
df.index = cudf.RangeIndex(len(objs[0]))
return df
elif not match_index:
return df.sort_index()
Expand Down Expand Up @@ -282,9 +282,15 @@ def concat(objs, axis=0, ignore_index=False, sort=None):
objs, axis=axis, ignore_index=ignore_index, sort=sort
)
elif typ is cudf.Series:
return cudf.Series._concat(
objs, axis=axis, index=None if ignore_index else True
)
objs = [obj for obj in objs if len(obj)]
if len(objs) == 0:
return cudf.Series()
elif len(objs) == 1 and not ignore_index:
return objs[0]
else:
return cudf.Series._concat(
objs, axis=axis, index=None if ignore_index else True
)
elif typ is cudf.MultiIndex:
return cudf.MultiIndex._concat(objs)
elif issubclass(typ, cudf.Index):
Expand Down
33 changes: 33 additions & 0 deletions python/cudf/cudf/tests/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,39 @@ def test_concat_empty_dataframes(df, other, ignore_index):
)


@pytest.mark.parametrize("ignore_index", [True, False])
@pytest.mark.parametrize("axis", [0, "index"])
@pytest.mark.parametrize(
marlenezw marked this conversation as resolved.
Show resolved Hide resolved
"data",
[
(["a", "b", "c"], ["a", "b", "c"]),
(["a", "b", "c"], ["XX", "YY", "ZZ"]),
],
)
def test_concat_empty_and_nonempty_series(ignore_index, data, axis):
s1 = gd.Series()
s2 = gd.Series(data[0])
ps1 = s1.to_pandas()
ps2 = s2.to_pandas()
got = gd.concat([s1, s2], axis=axis, ignore_index=ignore_index)
expect = pd.concat([ps1, ps2], axis=axis, ignore_index=ignore_index)

assert_eq(got, expect)


@pytest.mark.parametrize("ignore_index", [True, False])
@pytest.mark.parametrize("axis", [0, "index"])
def test_concat_two_empty_series(ignore_index, axis):
s1 = gd.Series()
s2 = gd.Series()
ps1 = s1.to_pandas()
ps2 = s2.to_pandas()
got = gd.concat([s1, s2], axis=axis, ignore_index=ignore_index)
expect = pd.concat([ps1, ps2], axis=axis, ignore_index=ignore_index)

assert_eq(got, expect)


@pytest.mark.parametrize(
"df1,df2",
[
Expand Down