BUG: upcasting on reshaping ops #13247
State: closed

Only rebasing and fixing the merge conflicts
Original work done by: @jennolsen84
Original branch: https://github.com/jennolsen84/pandas/tree/concatnan
Original PR: #13337 

 - [x] closes #13247
 - [x] tests added / passed
 - [x] passes ``git diff upstream/master | flake8 --diff``
 - [x] whatsnew entry


Labels:
name: Missing-data
description: np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
name: Dtype Conversions
description: Unexpected or buggy dtype conversions

Comments:
@jreback Copied the original test and used everything in it, except for `int` testing.

There are lots of things that needed to be fixed for this code, so I will keep working on it.

After 9 minutes, I found some errors while I was copying things over to this branch and all the tests seem fine except for the one I created for pytest.

Any guidance for pytest would be appreciated.


> Any guidance for pytest would be appreciated.

you can run individual tests with `pytest pandas -k <regex>`, so `pytest pandas -k test_concat_no_unnecessary_upcast_pytest`.

Let us know if you have other questions.
I got pytest working with the code.
@TomAugspurger @jreback Thank you guys for the help.
Hi, do I also need to fix additional errors in `text_index` and `test_reshape`?
yes everything needs to pass. fix up the tests as indicated and see if you can narrow down where the failures are.
```py
# these are coerced to float unavoidably (as its a list-like to begin)
        df = DataFrame(columns=['A', 'B'])
        df.loc[3] = [6, 7]
    
        exp = DataFrame([[6, 7]], index=[3], columns=['A', 'B'],
                        dtype='float64')
>       tm.assert_frame_equal(df, exp)
```
With this error, I am testing few things and I have few questions.
When I initialize with `df=DataFrame(columns['A','B'])` and do `df.loc[3] = [6,7]`, it is returning me `dtype: object`
If I do `df.loc[3] = [6.0, 7.0]`, A and B are `int64`, but `dtype` of data frame is still `object.`

This is not expected behavior correct?


# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/15594?src=pr&el=h1) Report
> Merging [#15594](https://codecov.io/gh/pandas-dev/pandas/pull/15594?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/5eac08a4f7fb2416fd7d3470e111d203a9a23feb?src=pr&el=desc) will **decrease** coverage by `0.02%`.
> The diff coverage is `91.66%`.


```diff
@@            Coverage Diff             @@
##           master   #15594      +/-   ##
==========================================
- Coverage   91.03%   91.01%   -0.03%     
==========================================
  Files         143      143              
  Lines       49382    49392      +10     
==========================================
- Hits        44957    44953       -4     
- Misses       4425     4439      +14
```


| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/15594?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/internals.py](https://codecov.io/gh/pandas-dev/pandas/compare/5eac08a4f7fb2416fd7d3470e111d203a9a23feb...3cd17344eea2a21f10bb796c54c2ad975f1674d2?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzLnB5) | `93.59% <91.66%> (-0.06%)` | :x: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/compare/5eac08a4f7fb2416fd7d3470e111d203a9a23feb...3cd17344eea2a21f10bb796c54c2ad975f1674d2?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :x: |
| [pandas/tools/merge.py](https://codecov.io/gh/pandas-dev/pandas/compare/5eac08a4f7fb2416fd7d3470e111d203a9a23feb...3cd17344eea2a21f10bb796c54c2ad975f1674d2?src=pr&el=tree#diff-cGFuZGFzL3Rvb2xzL21lcmdlLnB5) | `93.61% <0%> (-0.34%)` | :x: |
| [pandas/core/common.py](https://codecov.io/gh/pandas-dev/pandas/compare/5eac08a4f7fb2416fd7d3470e111d203a9a23feb...3cd17344eea2a21f10bb796c54c2ad975f1674d2?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tbW9uLnB5) | `90.96% <0%> (-0.34%)` | :x: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/compare/5eac08a4f7fb2416fd7d3470e111d203a9a23feb...3cd17344eea2a21f10bb796c54c2ad975f1674d2?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.87% <0%> (-0.1%)` | :x: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/15594?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/15594?src=pr&el=footer). Last update [5eac08a...3cd1734](https://codecov.io/gh/pandas-dev/pandas/compare/5eac08a4f7fb2416fd7d3470e111d203a9a23feb...3cd17344eea2a21f10bb796c54c2ad975f1674d2?src=pr&el=footer&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
@jreback Is this acceptable?
thanks @jaehoonhwang (and @jennolsen84 )


@jreback Thank you for the help. If there is any other old pr, I am happy to help.