Issue 1:
Hi,

I am running on the git cloned version of pandas, and there seems to be quite a few issues with user defined classes extending DataFrame.

It seems that DataFrame class constructor is hardcoded in a lot of places, where self.__class__ or cls constructors should be used instead. This causes some weird behaviour.

Allow me to illustrate, let's import pandas and define some class that would extend DataFrame

In[2]: import pandas as pd
In [3]: pd.__version__
Out[3]: '0.10.1'
In [4]: class ClassExtendingDataFrame(pd.DataFrame):
...: pass
...:

Note that ClassExtendingDataFrame does not override anything and is essentially the same DataFrame, just renamed.

Now one would expect a new instance of ClassExtendingDataFrame to be created by the following code:

In [5]: dict = {'a' : [1,2,3], 'b': [2,3,4]}
In [6]: x = ClassExtendingDataFrame.from_dict(dict)

Unfortunately:

In [10]: assert(isinstance(x, ClassExtendingDataFrame))
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-10-3f1ceeb1b90f> in <module>()
----> 1 assert(isinstance(x, ClassExtendingDataFrame))

AssertionError:

In [11]: type(x)
Out[11]: pandas.core.frame.DataFrame

This is due to DataFrame being hardcoded in from_dict: https://github.com/pydata/pandas/blob/master/pandas/core/frame.py#L905 .

cls variable should be used here.

Note that ClassExtendingDataFrame is initialised using constructor, rather than from_dict method, correct object is created:

In [12]: a = ClassExtendingDataFrame(dict)
In [13]: isinstance(a, ClassExtendingDataFrame)
Out[13]: True

However, operations as simple as slicing break this:

In [14]: isinstance(a[:5], ClassExtendingDataFrame)
Out[14]: False

These are just the two examples I have noticed myself, but I am sure there could be more.

A thorough review of Hardcoded DataFrame constructors is needed to check if they could be replaced by self.__class__ or cls instead.

Issue 2:
https://travis-ci.org/pandas-dev/pandas/jobs/267760269

Master and some PRs (strangely not all) are all failing on the same test, but only on Mac:

=================================== FAILURES ===================================
_____________________ TestCategoricalIndex.test_reindexing _____________________
[gw1] darwin -- Python 3.5.4 /Users/travis/miniconda3/envs/pandas/bin/python
self = <pandas.tests.indexes.test_category.TestCategoricalIndex object at 0x111d5e860>
def test_reindexing(self):

ci = self.create_index()
oidx = Index(np.array(ci))

for n in [1, 2, 5, len(ci)]:
finder = oidx[np.random.randint(0, len(ci), size=n)]
expected = oidx.get_indexer_non_unique(finder)[0]

actual = ci.get_indexer(finder)
> tm.assert_numpy_array_equal(expected, actual)
pandas/tests/indexes/test_category.py:389:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pandas/util/testing.py:1174: in assert_numpy_array_equal
_raise(left, right, err_msg)
pandas/util/testing.py:1157: in _raise
.format(obj=obj), left.shape, right.shape)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
obj = 'numpy array', message = 'numpy array shapes are different', left = (14,)
right = (6,), diff = None
def raise_assert_detail(obj, message, left, right, diff=None):
if isinstance(left, np.ndarray):
left = pprint_thing(left)
if isinstance(right, np.ndarray):
right = pprint_thing(right)

msg = """{obj} are different

{message}
[left]: {left}
[right]: {right}""".format(obj=obj, message=message, left=left, right=right)

if diff is not None:
msg += "\n[diff]: {diff}".format(diff=diff)

> raise AssertionError(msg)
E AssertionError: numpy array are different
E
E numpy array shapes are different
E [left]: (14,)
E [right]: (6,)
pandas/util/testing.py:1105: AssertionError