BUG: Swap byteorder in constructor of Block Manager (#4737)
State: closed

- [x] closes #4737
- [x] tests added / passed (at least the test_internals.py)
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

This is one possible approach to directly change the dtypes to the native byteorder in the constructor of the BlockManager. This code does it automatically, without the user deciding a swap, so I am not sure if this is a wise design decision.
Another concern is the speed of conversion into a pandas object. I didn't quite grasp the asv stuff, so maybe someone else can check for me (sorry!).
I will add something to whatsnew, after you have confirmed, that this method of doing it is okay.

Please tell me if I forgot to do something.




Labels:
name: Error Reporting
description: Incorrect or improved errors from pandas
name: Internals
description: Related to non-user accessible pandas implementation

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

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

```diff
@@            Coverage Diff             @@
##           master   #22282      +/-   ##
==========================================
- Coverage   92.23%   92.08%   -0.15%     
==========================================
  Files         161      169       +8     
  Lines       51197    50708     -489     
==========================================
- Hits        47220    46694     -526     
- Misses       3977     4014      +37
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.49% <100%> (-0.13%)` | :arrow_down: |
| #single | `42.33% <100%> (+0.06%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/22282?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/internals/managers.py](https://codecov.io/gh/pandas-dev/pandas/pull/22282/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL21hbmFnZXJzLnB5) | `96.58% <100%> (+0.85%)` | :arrow_up: |
| [pandas/io/formats/console.py](https://codecov.io/gh/pandas-dev/pandas/pull/22282/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvY29uc29sZS5weQ==) | `65.15% <0%> (-10.61%)` | :arrow_down: |
| [pandas/core/arrays/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/22282/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2Jhc2UucHk=) | `87.85% <0%> (-10.16%)` | :arrow_down: |
| [pandas/core/dtypes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/22282/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Jhc2UucHk=) | `92.3% <0%> (-7.7%)` | :arrow_down: |
| [pandas/errors/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/22282/diff?src=pr&el=tree#diff-cGFuZGFzL2Vycm9ycy9fX2luaXRfXy5weQ==) | `92.3% <0%> (-7.7%)` | :arrow_down: |
| [pandas/plotting/\_tools.py](https://codecov.io/gh/pandas-dev/pandas/pull/22282/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL190b29scy5weQ==) | `72.62% <0%> (-6.15%)` | :arrow_down: |
| [pandas/core/arrays/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/22282/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3BlcmlvZC5weQ==) | `91.98% <0%> (-6.1%)` | :arrow_down: |
| [pandas/io/feather\_format.py](https://codecov.io/gh/pandas-dev/pandas/pull/22282/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2ZlYXRoZXJfZm9ybWF0LnB5) | `85.71% <0%> (-4.03%)` | :arrow_down: |
| [pandas/core/arrays/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/22282/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lcy5weQ==) | `95.52% <0%> (-3.32%)` | :arrow_down: |
| [pandas/plotting/\_style.py](https://codecov.io/gh/pandas-dev/pandas/pull/22282/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19zdHlsZS5weQ==) | `74.28% <0%> (-3.14%)` | :arrow_down: |
| ... and [123 more](https://codecov.io/gh/pandas-dev/pandas/pull/22282/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22282?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/22282?src=pr&el=footer). Last update [d78bd7a...8e972ec](https://codecov.io/gh/pandas-dev/pandas/pull/22282?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

The code is not specific for little endian. I am not sure how we should test this on non-little-endian systems, is it possible through Travis or other ci's?
Hello @MHC03! Thanks for updating the PR.

 - There are no PEP8 issues in the file [`pandas/core/internals/managers.py`](https://github.com/MHC03/pandas/blob/8e972eca07ede4b03a2b64d92efee5200486d969/pandas/core/internals/managers.py) !

 - There are no PEP8 issues in the file [`pandas/tests/internals/test_internals.py`](https://github.com/MHC03/pandas/blob/8e972eca07ede4b03a2b64d92efee5200486d969/pandas/tests/internals/test_internals.py) !


closing as stale. ping if you'd like to continue.