Repository: pandas-dev/pandas

Issue:
Cannot create a DataFrame from list subclass
#### Code Sample, a copy-pastable example if possible

```python
import pandas

class List(list):
    pass

pandas.DataFrame(List([List([1,2,3]), List([4,5,6])]))
```
```
TypeError: Argument 'rows' has incorrect type (expected list, got List)
```

#### Problem description

It seems it is not possible to create a DataFrame from subclasses of lists. The code seems to have a too strict check.

#### Expected Output

It should create a DataFrame like it would with regular lists.

#### Output of ``pd.show_versions()``

<details>


INSTALLED VERSIONS
------------------
commit: None
python: 3.6.3.final.0
python-bits: 64
OS: Linux
OS-release: 4.13.0-41-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.22.0
pytest: 3.3.0
pip: 9.0.1
setuptools: 39.1.0
Cython: 0.28.2
numpy: 1.14.3
scipy: 1.0.0
pyarrow: 0.9.0
xarray: None
IPython: 6.2.1
sphinx: 1.7.4
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.1.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.999999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.4
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None


</details>



Discussion:
It's not a too strict check in itself, but we have typed cython code that does this conversion of lists to array. And it is that code that expects an actual `list`. 
I don't know if having this typed actually gives a speed-up or not.
I mean, even if it is faster if just lists is provided to cython, it should still just work if it is a subclass, no?
import pandas as pd
class lis():
     def l1(x):
        x=[45,67,89,9]
        m=[67,89,23,45]
        y=pd.DataFrame(x, m)
        print(y)

a=lis()
a.l1()
import pandas as pd
class lis():
     def l1(x):
        x={'a':[1,4,7,8],'b':[77,88,99,55]}
        y=pd.DataFrame(x)
        print(y)

a=lis()
a.l1()
import pandas as pd
class lis():
     def l1(x):
        a=[1,4,7,8]
        b=[77,88,99,55]
        y=pd.DataFrame({'a':a,'b':b})
        print(y)

a=lis()
a.l1()

Resolving patch:
diff --git a/asv_bench/benchmarks/frame_ctor.py b/asv_bench/benchmarks/frame_ctor.py
--- a/asv_bench/benchmarks/frame_ctor.py
+++ b/asv_bench/benchmarks/frame_ctor.py
@@ -91,4 +91,17 @@ def time_frame_from_ndarray(self):
         self.df = DataFrame(self.data)
 
 
+class FromLists(object):
+
+    goal_time = 0.2
+
+    def setup(self):
+        N = 1000
+        M = 100
+        self.data = [[j for j in range(M)] for i in range(N)]
+
+    def time_frame_from_lists(self):
+        self.df = DataFrame(self.data)
+
+
 from .pandas_vb_common import setup  # noqa: F401


Test patch:
diff --git a/pandas/tests/frame/test_constructors.py b/pandas/tests/frame/test_constructors.py
--- a/pandas/tests/frame/test_constructors.py
+++ b/pandas/tests/frame/test_constructors.py
@@ -2165,6 +2165,15 @@ def test_constructor_range_dtype(self, dtype):
         result = DataFrame({'A': range(5)}, dtype=dtype)
         tm.assert_frame_equal(result, expected)
 
+    def test_frame_from_list_subclass(self):
+        # GH21226
+        class List(list):
+            pass
+
+        expected = DataFrame([[1, 2, 3], [4, 5, 6]])
+        result = DataFrame(List([List([1, 2, 3]), List([4, 5, 6])]))
+        tm.assert_frame_equal(result, expected)
+
 
 class TestDataFrameConstructorWithDatetimeTZ(TestData):