Fixed tuple to List Conversion in Dataframe class
State: closed

- [X] closes #25075 
- [X] tests added / passed
- [X] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [X] whatsnew entry

Traceback of issue #25075 
- [pandas/core/frame.py: L#435](https://github.com/pandas-dev/pandas/blob/master/pandas/core/frame.py#L435) `to_arrays(data, columns, dtype=dtype)`
- [pandas/core/internals/construction.py: L#403](https://github.com/pandas-dev/pandas/blob/master/pandas/core/internals/construction.py#L403) `_list_to_arrays(data, columns, coerce_float=coerce_float, dtype=dtype)`
- [pandas/core/internals/construction.py: L#434](https://github.com/pandas-dev/pandas/blob/master/pandas/core/internals/construction.py#L434) `lib.to_object_array(data)`
- [pandas/_libs/lib.pyx: L#2283](https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/lib.pyx#L2283) `row[j]`

### Cause of "Segmentation fault"
**row** variable as declared on [line#2266](https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/lib.pyx#L2266) has to be of _list_ type.
It is tried to assign a tuple by converting to a list on [line#2280](https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/lib.pyx#L2280) using `row = <list>input_rows[i]`
The conversion fails. As a result, the type of **row** is tuple (not a list) after line#2280. The `Segmentation fault` is returned when tried to access a value from it at [line#2283](https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/lib.pyx#L2283)

### Fixes in #25089 
- At [line#2280](https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/lib.pyx#L2280) in [_libs/lib.pyx](https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/lib.pyx), changed the style of converting tuple into list.
  `<list>` --> `list()`
  This successfully converts tuples into list and further exception does not occur. As a result, function `to_object_array` correctly returns the numpy ndarray, what it's supposed to return.

As a result, not only `Segmentation fault` is removed, the need of function to raise `Type Error` is also eliminated.

Labels:
name: Bug
name: Reshaping
description: Concat, Merge/Join, Stack/Unstack, Explode

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25089?src=pr&el=h1) Report
> Merging [#25089](https://codecov.io/gh/pandas-dev/pandas/pull/25089?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/bb43726e1f52a0ddee45fcf485690719f262870d?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

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

```diff
@@           Coverage Diff           @@
##           master   #25089   +/-   ##
=======================================
  Coverage   92.37%   92.37%           
=======================================
  Files         166      166           
  Lines       52420    52420           
=======================================
  Hits        48423    48423           
  Misses       3997     3997
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.79% <ø> (ø)` | :arrow_up: |
| #single | `42.88% <ø> (ø)` | :arrow_up: |


------

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

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25089?src=pr&el=h1) Report
> Merging [#25089](https://codecov.io/gh/pandas-dev/pandas/pull/25089?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/e3b095074c5c3b29ec25a994cd204349b872d961?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

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

```diff
@@           Coverage Diff           @@
##           master   #25089   +/-   ##
=======================================
  Coverage   92.37%   92.37%           
=======================================
  Files         166      166           
  Lines       52408    52408           
=======================================
  Hits        48412    48412           
  Misses       3996     3996
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.79% <ø> (ø)` | :arrow_up: |
| #single | `42.88% <ø> (+0.02%)` | :arrow_up: |


------

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

Hey thanks for the PR - mind writing a simple test to check this raises a Type Error?
@alimcmaster1 Please review the fixes made in this PR.
### Fixes in #25089 
- At [line#2280](https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/lib.pyx#L2280) in [_libs/lib.pyx](https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/lib.pyx), changed the style of converting tuple into list.
  `<list>` --> `list()`
  This successfully converts tuples into list and further exception does not occur. As a result, function `to_object_array` correctly returns the numpy ndarray, what it's supposed to return.

As a result, not only `Segmentation fault` is removed, the need of function to raise `Type Error` is also eliminated.
>     * needs a test (put in tests/frame/test_constructor.py)
> 
>     * whatsnew for 0.24.2
> 
>     * pls do an asv check

@jreback Will be adding the tests soon.
I'm not exactly aware about the **asv check** though.
Can you please explain me what it is or just point me to a good link.
http://pandas.pydata.org/pandas-docs/stable/development/contributing.html#running-the-performance-test-suite
- [X] added tests
- [X] modified whatsnew
- [X] performed asv check

@jreback Made all the requested changes.
Hello @Vibhu-Agarwal! Thanks for updating the PR.



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

##### Comment last updated on February 05, 2019 at 05:04 Hours UTC
@jreback Made all the requested changes and removed all unnecessary lines in whatsnew.
can you run the appropriate asvs for this
@jreback performed asv check with frame constructors (frame_ctor)
The report says `BENCHMARKS NOT SIGNIFICANTLY CHANGED.`
thanks @Vibhu-Agarwal