ERR: Raise ValueError when setting scalars in a dataframe with no index ( #16823)
State: closed

 - [x] closes  #16823
 - [x] tests added / passed
 - [x] passes ``git diff upstream/master -u -- "*.py" | flake8 --diff``
 - [x] whatsnew entry

Trying to set a column with an scalar value and no index now raises a ValueError, similar to the behaviour of the DataFrame constructor.


Labels:
name: Indexing
description: Related to indexing on series/frames, not to indexes themselves
name: Error Reporting
description: Incorrect or improved errors from pandas

Comments:
Hello @alanbato! Thanks for updating the PR.













Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on October 08, 2017 at 16:21 Hours UTC
Do you know why the CI checks are failing?
u just click thru

https://travis-ci.org/pandas-dev/pandas/jobs/254061811
can you rebase
can you rebase. code looks ok .
@jreback Sorry, I didn't see the previous comments. I rebased, but I still think some tests were broken due to this new error raising and not being caught in them. should I change these tests?
yes if we have tests doing this then they should be changed
Okay, I will change the failing tests once I build the C extensions that for some reason stop working everytime I reboot 🤔  Thanks Jeff!
we have been merging a fair amount of extensions (c code) recently ; always a good practice to build extensions when u pull (and if nothing changes it doesn't do anythinh)
The tests pass now, but I feel some previous behavior will need more suitable errors (like the `crosstab` one). Maybe make it a separate issue?

PD: Thanks, I thought it had to do with my machine. Will rebuild every pull from now on then
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16968?src=pr&el=h1) Report
> Merging [#16968](https://codecov.io/gh/pandas-dev/pandas/pull/16968?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/e63c935d5a0705f83fc726932eb82bac4c272106?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `83.33%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/16968/graphs/tree.svg?src=pr&token=eZ4WkYLtcO&width=650&height=150)](https://codecov.io/gh/pandas-dev/pandas/pull/16968?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #16968      +/-   ##
==========================================
- Coverage   91.26%   91.24%   -0.02%     
==========================================
  Files         163      163              
  Lines       49978    49980       +2     
==========================================
- Hits        45611    45604       -7     
- Misses       4367     4376       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.04% <83.33%> (ø)` | :arrow_up: |
| #single | `40.24% <33.33%> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16968?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/reshape/pivot.py](https://codecov.io/gh/pandas-dev/pandas/pull/16968?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzaGFwZS9waXZvdC5weQ==) | `96.38% <100%> (+0.02%)` | :arrow_up: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/16968?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.74% <75%> (-0.1%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/16968?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/groupby.py](https://codecov.io/gh/pandas-dev/pandas/pull/16968?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS5weQ==) | `91.99% <0%> (-0.05%)` | :arrow_down: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/16968?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `95.58% <0%> (ø)` | :arrow_up: |
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/16968?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `97.09% <0%> (+0.2%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16968?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16968?src=pr&el=footer). Last update [e63c935...e86db7f](https://codecov.io/gh/pandas-dev/pandas/pull/16968?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@jreback Ping! 🌵✔️ 
Rewrote the behavior on non-overlaping frames and redid the test to make it pass as it should.
lgtm. ping on green.
@jreback Ping! 🌵 ☑️ 
@alanbato the CI tests failed. https://travis-ci.org/pandas-dev/pandas/jobs/283492196#L1377 looks relevant to your changes here.
@TomAugspurger Yes, now I remember why I changed that return value, haha. But the output I'm getting from this non-overlapping crosstab is `DataFrame(index=[], columns=['row_0','col_0'])` and excuse me if I'm wrong but I'm not sure we want that output.
Correct me if I'm wrong, but wouldn't it make sense to return an empty dataframe when this happens? 
We were trying to preserve the `Index`, but my understanding is that this non-overlapping chase always results in an `Index: []`
I pushed a fix here.
I reverted to the previous.
thanks @alanbato 
Thank you @jreback!