# Buggy code
def _sanitize_column(self, key, value):
    # Need to make sure new columns (which go into the BlockManager as new
    # blocks) are always copied

    def reindexer(value):
        # reindex if necessary

        if value.index.equals(self.index) or not len(self.index):
            value = value._values.copy()
        else:
            # GH 4107
            try:
                value = value.reindex(self.index).values
            except Exception as e:
                # duplicate axis
                if not value.index.is_unique:
                    raise e

                # other
                raise TypeError(
                    "incompatible index of inserted column with frame index"
                )
        return value

    if isinstance(value, Series):
        value = reindexer(value)

    elif isinstance(value, DataFrame):
        # align right-hand-side columns if self.columns
        # is multi-index and self[key] is a sub-frame
        if isinstance(self.columns, MultiIndex) and key in self.columns:
            loc = self.columns.get_loc(key)
            if isinstance(loc, (slice, Series, np.ndarray, Index)):
                cols = maybe_droplevels(self.columns[loc], key)
                if len(cols) and not cols.equals(value.columns):
                    value = value.reindex_axis(cols, axis=1)
        # now align rows
        value = reindexer(value).T

    elif isinstance(value, Categorical):
        value = value.copy()

    elif isinstance(value, Index) or is_sequence(value):
        from pandas.core.series import _sanitize_index

        # turn me into an ndarray
        value = _sanitize_index(value, self.index, copy=False)
        if not isinstance(value, (np.ndarray, Index)):
            if isinstance(value, list) and len(value) > 0:
                value = com._possibly_convert_platform(value)
            else:
                value = com._asarray_tuplesafe(value)
        elif value.ndim == 2:
            value = value.copy().T
        else:
            value = value.copy()

        # possibly infer to datetimelike
        if is_object_dtype(value.dtype):
            value = _possibly_infer_to_datetimelike(value)

    else:
        # upcast the scalar
        dtype, value = _infer_dtype_from_scalar(value)
        value = np.repeat(value, len(self.index)).astype(dtype)
        value = com._possibly_cast_to_datetime(value, dtype)

    # return internal types directly
    if is_internal_type(value):
        return value

    # broadcast across multiple columns if necessary
    if key in self.columns and value.ndim == 1:
        if not self.columns.is_unique or isinstance(self.columns, MultiIndex):
            existing_piece = self[key]
            if isinstance(existing_piece, DataFrame):
                value = np.tile(value, (len(existing_piece.columns), 1))

    return np.atleast_2d(np.asarray(value))


# Traceback (TypeError)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-ba941613799a> in <module>()
----> 1 df.publication_timestamp.map(lambda x: x)

/Users/johria/.pyenv/versions/3.5.1/lib/python3.5/site-packages/pandas/core/series.py in map(self, arg, na_action)
2052                                      index=self.index).__finalize__(self)
2053         else:
-> 2054             mapped = map_f(values, arg)
2055             return self._constructor(mapped,
2056                                      index=self.index).__finalize__(self)

TypeError: Argument 'arr' has incorrect type (expected numpy.ndarray, got DatetimeIndex)

# Fixed code
def _sanitize_column(self, key, value):
    # Need to make sure new columns (which go into the BlockManager as new
    # blocks) are always copied

    def reindexer(value):
        # reindex if necessary

        if value.index.equals(self.index) or not len(self.index):
            value = value._values.copy()
        else:
            # GH 4107
            try:
                value = value.reindex(self.index).values
            except Exception as e:
                # duplicate axis
                if not value.index.is_unique:
                    raise e

                # other
                raise TypeError(
                    "incompatible index of inserted column with frame index"
                )
        return value

    if isinstance(value, Series):
        value = reindexer(value)

    elif isinstance(value, DataFrame):
        # align right-hand-side columns if self.columns
        # is multi-index and self[key] is a sub-frame
        if isinstance(self.columns, MultiIndex) and key in self.columns:
            loc = self.columns.get_loc(key)
            if isinstance(loc, (slice, Series, np.ndarray, Index)):
                cols = maybe_droplevels(self.columns[loc], key)
                if len(cols) and not cols.equals(value.columns):
                    value = value.reindex_axis(cols, axis=1)
        # now align rows
        value = reindexer(value).T

    elif isinstance(value, Categorical):
        value = value.copy()

    elif isinstance(value, Index) or is_sequence(value):
        from pandas.core.series import _sanitize_index

        # turn me into an ndarray
        value = _sanitize_index(value, self.index, copy=False)
        if not isinstance(value, (np.ndarray, Index)):
            if isinstance(value, list) and len(value) > 0:
                value = com._possibly_convert_platform(value)
            else:
                value = com._asarray_tuplesafe(value)
        elif value.ndim == 2:
            value = value.copy().T
        else:
            value = value.copy()

        # possibly infer to datetimelike
        if is_object_dtype(value.dtype):
            value = _possibly_infer_to_datetimelike(value)

    else:
        # upcast the scalar
        dtype, value = _infer_dtype_from_scalar(value)
        value = np.repeat(value, len(self.index)).astype(dtype)
        value = com._possibly_cast_to_datetime(value, dtype)

    # return internal types directly
    if is_extension_type(value):
        return value

    # broadcast across multiple columns if necessary
    if key in self.columns and value.ndim == 1:
        if not self.columns.is_unique or isinstance(self.columns, MultiIndex):
            existing_piece = self[key]
            if isinstance(existing_piece, DataFrame):
                value = np.tile(value, (len(existing_piece.columns), 1))

    return np.atleast_2d(np.asarray(value))