Skip to content

.loc for appending/assigning multiple values #6173

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

Closed
aldanor opened this issue Jan 29, 2014 · 2 comments · Fixed by #23806
Closed

.loc for appending/assigning multiple values #6173

aldanor opened this issue Jan 29, 2014 · 2 comments · Fixed by #23806
Labels
Dtype Conversions Unexpected or buggy dtype conversions Enhancement good first issue Indexing Related to indexing on series/frames, not to indexes themselves Needs Tests Unit test(s) needed to prevent regressions
Milestone

Comments

@aldanor
Copy link
Contributor

aldanor commented Jan 29, 2014

According to the latest v0.13 docs .loc can append, but can it (or rather, should it?) append more than one value at once?

Setting multiple via .loc:

>>> df = pd.DataFrame(columns=['x', 'y'])
>>> df.loc[:, 'x'] = [1, 2]
>>> df
Empty DataFrame
Columns: [x, y]
Index: []
>>> df.loc[[0, 1], 'x'] = [1, 2]
>>> df
Empty DataFrame
Columns: [x, y]
Index: []
>>> df.loc[0:2, 'x'] = [1, 2]
>>> df
Empty DataFrame
Columns: [x, y]
Index: []

Setting single via .loc: (works as intended)

>>> df = pd.DataFrame(columns=['x', 'y'])
>>> df.loc[0, 'x'] = 1
>>> df
   x    y
0  1  NaN
@aldanor
Copy link
Contributor Author

aldanor commented Jan 29, 2014

Ref: #6171

@jreback jreback modified the milestones: 0.15.0, 0.14.0 Feb 18, 2014
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 3, 2015
@mroeschke
Copy link
Member

These all work now as expected. Looks like some tests could be added to confirm this behavior.

@mroeschke mroeschke added Testing pandas testing functions or related to the test suite good first issue labels Jul 6, 2018
@jreback jreback modified the milestones: Contributions Welcome, 0.24.0 Jul 7, 2018
@jreback jreback added Needs Tests Unit test(s) needed to prevent regressions and removed Testing pandas testing functions or related to the test suite labels Jul 7, 2018
@jreback jreback modified the milestones: 0.24.0, Contributions Welcome Nov 6, 2018
@jreback jreback modified the milestones: Contributions Welcome, 0.24.0 Nov 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Enhancement good first issue Indexing Related to indexing on series/frames, not to indexes themselves Needs Tests Unit test(s) needed to prevent regressions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants