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

Support setting to a new column in DataFrame.loc #8012

Merged
merged 2 commits into from
Apr 21, 2021

Conversation

isVoid
Copy link
Contributor

@isVoid isVoid commented Apr 20, 2021

closes #7628

This PR adds support to setting a column in the dataframe when the provided column name is a new column name. The specified rows can be of a single row label, a collection of row labels, or slices. The value-to-set can be column-like object or scalar. E.g. you can now do this:

>>> x = cudf.DataFrame()
>>> x.loc[:, "a"] = [1, 2, 3] # set a new column with list
>>> x
   a
0  1
1  2
2  3
>>> x.loc[[1, 2], "b"] = ["abc", "cba"] # set part of the new column with list
>>> x
   a     b
0  1  <NA>
1  2   abc
2  3   cba
>>> x.loc[:, "c"] = 5 # set the new column to the scalar
>>> x
   a     b  c
0  1  <NA>  5
1  2   abc  5
2  3   cba  5

@isVoid isVoid requested a review from a team as a code owner April 20, 2021 23:03
@isVoid isVoid self-assigned this Apr 20, 2021
@github-actions github-actions bot added the Python Affects Python cuDF API. label Apr 20, 2021
@isVoid isVoid added non-breaking Non-breaking change bug Something isn't working Python Affects Python cuDF API. 3 - Ready for Review Ready for review by team and removed Python Affects Python cuDF API. labels Apr 20, 2021
@galipremsagar
Copy link
Contributor

rerun tests

@codecov
Copy link

codecov bot commented Apr 21, 2021

Codecov Report

Merging #8012 (5537aa7) into branch-0.20 (51336df) will increase coverage by 0.04%.
The diff coverage is 90.47%.

❗ Current head 5537aa7 differs from pull request most recent head 148f0f3. Consider uploading reports for the commit 148f0f3 to get more accurate results
Impacted file tree graph

@@               Coverage Diff               @@
##           branch-0.20    #8012      +/-   ##
===============================================
+ Coverage        82.88%   82.93%   +0.04%     
===============================================
  Files              103      103              
  Lines            17668    17678      +10     
===============================================
+ Hits             14645    14662      +17     
+ Misses            3023     3016       -7     
Impacted Files Coverage Δ
python/cudf/cudf/core/column/__init__.py 100.00% <ø> (ø)
python/cudf/cudf/io/orc.py 86.89% <ø> (ø)
python/cudf/cudf/utils/cudautils.py 57.75% <25.00%> (ø)
python/cudf/cudf/core/column/column.py 88.64% <71.42%> (ø)
python/cudf/cudf/core/column/numerical.py 94.43% <72.72%> (ø)
python/dask_cudf/dask_cudf/backends.py 89.51% <80.00%> (-0.08%) ⬇️
python/cudf/cudf/core/dataframe.py 90.87% <83.33%> (+0.01%) ⬆️
python/cudf/cudf/utils/utils.py 89.53% <91.66%> (+0.02%) ⬆️
python/cudf/cudf/core/column/datetime.py 89.91% <100.00%> (ø)
python/cudf/cudf/core/column/timedelta.py 88.66% <100.00%> (ø)
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d501d2c...148f0f3. Read the comment docs.

@galipremsagar galipremsagar added 5 - Ready to Merge Testing and reviews complete, ready to merge and removed 3 - Ready for Review Ready for review by team labels Apr 21, 2021
@kkraus14
Copy link
Collaborator

@gpucibot merge

@rapids-bot rapids-bot bot merged commit d4d64c0 into rapidsai:branch-0.20 Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to Merge Testing and reviews complete, ready to merge bug Something isn't working non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] loc doesn't enlarge dataframe on fresh column names
3 participants