BUG/API: Indexes on empty frames/series should be RangeIndex
- [x] closes #40077
- [x] closes #49572

I've looked into #49572 and it seems that the fix is reasonable simple, see included code. In short, currently if the user hasn't supplied `index` or `columns` values, then the index/columns is a `RangeIndex` if the data has lenght > 0, while they're `Index[object]` if the length is 0. After this PR, a `RangeIndex` will be used in both cases. This will simplify type inference etc. testing etc.

However, this fix requires changes to a lot of tests (>500), of which I've fixed about 100 (not included in this version of the PR), so it's quite a lot of work to get this fixed up. Test fixing so far seems to be only a matter of ensuring that various empty dataframes/Series have `RangeIndex` rather than a `Index[object]`, so relatively simple, but also tedious work.

I didn't get much response to #49572 from the core devs, so before I spend more time on this rather big item, could you guys chime in on if you agree that this a good thing to do? IMO having the same index dtypes for series/frame of length 0 and >0 will conceptually simplify pandas and decrease the amount of surprises that users will encounter.

I've included the code  that fixes the issue in this PR, as mentioned, and ATM this PR fails, because I haven't fixed the tests, but I will get them fixed if I get positive response. If you can respond either here or in #49572, I'll of course read them both.


@pandas-dev/pandas-core any comment?

IMO, this simplify the construction logic nicely, so will be good to get in. I think this is also a sensible change for 2.0.0.   this doesn't break any tests? @jreback , this break a lot  of tests, as empty series/frames are in a lot of tests. So I  wanted to know it if others approve of this general idea/change, before really going through the tests. I would be supportive of this change; IMO it would needs its own section in the 2.0 whatsnew closes #40077? Still need docs + some cleanup, otherwise is ready if passes the CI. > closes #40077?

Yes, this makes it so the index of the `df` is a `RangeIndex`, so the example in #40077 passes after this PR. This is ready for review now. Updated. Updated. Rebased & updated. Gentle ping. I've rebased (no code changes) just in case. Thanks @topper-123 