gurudesh/pytracebugs huggingface dataset:
# Buggy code
def from_blocks(cls, blocks, index):
    # also checks for overlap
    items = _union_block_items(blocks)
    return BlockManager(blocks, [items, index])


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def from_blocks(cls, blocks, index):
    # also checks for overlap
    items = _union_block_items(blocks)
    for blk in blocks:
        blk.ref_items = items
    return BlockManager(blocks, [items, index])
# Buggy code
def _interleave(self, items):
    """
    Return ndarray from blocks with specified item order
    Items must be contained in the blocks
    """
    dtype = _interleaved_dtype(self.blocks)
    items = _ensure_index(items)

    result = np.empty(self.shape, dtype=dtype)
    itemmask = np.zeros(len(items), dtype=bool)

    # By construction, all of the item should be covered by one of the
    # blocks
    for block in self.blocks:
        indexer = items.get_indexer(block.items)
        assert (indexer != -1).all()
        result[indexer] = block.values
        itemmask[indexer] = 1
    assert itemmask.all()
    return result


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def _interleave(self, items):
    """
    Return ndarray from blocks with specified item order
    Items must be contained in the blocks
    """
    dtype = _interleaved_dtype(self.blocks)
    items = _ensure_index(items)

    result = np.empty(self.shape, dtype=dtype)
    itemmask = np.zeros(len(items), dtype=bool)

    # By construction, all of the item should be covered by one of the
    # blocks
    for block in self.blocks:
        indexer = items.get_indexer(block.items)
        assert (indexer != -1).all()
        result[indexer] = block.get_values(dtype)
        itemmask[indexer] = 1
    assert itemmask.all()
    return result
# Buggy code
def rename_axis(self, mapper, axis=1):
    new_axis = Index([mapper(x) for x in self.axes[axis]])
    new_axis._verify_integrity()

    new_axes = list(self.axes)
    new_axes[axis] = new_axis
    return BlockManager(self.blocks, new_axes)


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def rename_axis(self, mapper, axis=1):
    new_axis = Index([mapper(x) for x in self.axes[axis]])
    assert new_axis.is_unique

    new_axes = list(self.axes)
    new_axes[axis] = new_axis
    return BlockManager(self.blocks, new_axes)
# Buggy code
def rename_items(self, mapper, copydata=True):
    new_items = Index([mapper(x) for x in self.items])
    new_items._verify_integrity()

    new_blocks = []
    for block in self.blocks:
        newb = block.copy(deep=copydata)
        newb.set_ref_items(new_items, maybe_rename=True)
        new_blocks.append(newb)
    new_axes = list(self.axes)
    new_axes[0] = new_items
    return BlockManager(new_blocks, new_axes)


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def rename_items(self, mapper, copydata=True):
    new_items = Index([mapper(x) for x in self.items])
    new_items.is_unique

    new_blocks = []
    for block in self.blocks:
        newb = block.copy(deep=copydata)
        newb.set_ref_items(new_items, maybe_rename=True)
        new_blocks.append(newb)
    new_axes = list(self.axes)
    new_axes[0] = new_items
    return BlockManager(new_blocks, new_axes)
# Buggy code
def fillna(self, value, inplace=False):
    """ """
    new_blocks = [
        b.fillna(value, inplace=inplace) if b._can_hold_na else b for b in self.blocks
    ]
    if inplace:
        return self
    return BlockManager(new_blocks, self.axes)


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def fillna(self, value, inplace=False):
    new_blocks = [
        b.fillna(value, inplace=inplace) if b._can_hold_na else b for b in self.blocks
    ]
    if inplace:
        return self
    return BlockManager(new_blocks, self.axes)
# Buggy code
def _stack_dict(dct, ref_items, dtype):
    from pandas.core.series import Series

    # fml
    def _asarray_compat(x):
        # asarray shouldn't be called on SparseSeries
        if isinstance(x, Series):
            return x.values
        else:
            return np.asarray(x)

    def _shape_compat(x):
        # sparseseries
        if isinstance(x, Series):
            return (len(x),)
        else:
            return x.shape

    items = [x for x in ref_items if x in dct]

    first = dct[items[0]]
    shape = (len(dct),) + _shape_compat(first)

    stacked = np.empty(shape, dtype=dtype)
    for i, item in enumerate(items):
        stacked[i] = _asarray_compat(dct[item])

    # stacked = np.vstack([_asarray_compat(dct[k]) for k in items])
    return items, stacked


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def _stack_dict(dct, ref_items, dtype):
    from pandas.core.series import Series

    # fml
    def _asarray_compat(x):
        # asarray shouldn't be called on SparseSeries
        if isinstance(x, Series):
            return x.values
        else:
            return np.asarray(x)

    def _shape_compat(x):
        # sparseseries
        if isinstance(x, Series):
            return (len(x),)
        else:
            return x.shape

    # index may box values
    items = ref_items[[x in dct for x in ref_items]]

    first = dct[items[0]]
    shape = (len(dct),) + _shape_compat(first)

    stacked = np.empty(shape, dtype=dtype)
    for i, item in enumerate(items):
        stacked[i] = _asarray_compat(dct[item])

    # stacked = np.vstack([_asarray_compat(dct[k]) for k in items])
    return items, stacked
# Buggy code
def _interleaved_dtype(blocks):
    from collections import defaultdict

    counts = defaultdict(lambda: 0)
    for x in blocks:
        counts[type(x)] += 1

    have_int = counts[IntBlock] > 0
    have_bool = counts[BoolBlock] > 0
    have_object = counts[ObjectBlock] > 0
    have_float = counts[FloatBlock] > 0
    have_numeric = have_float or have_int

    if have_object:
        return np.object_
    elif have_bool and have_numeric:
        return np.object_
    elif have_bool:
        return np.bool_
    elif have_int and not have_float:
        return np.int64
    else:
        return np.float64


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def _interleaved_dtype(blocks):
    from collections import defaultdict

    counts = defaultdict(lambda: 0)
    for x in blocks:
        counts[type(x)] += 1

    have_int = counts[IntBlock] > 0
    have_bool = counts[BoolBlock] > 0
    have_object = counts[ObjectBlock] > 0
    have_float = counts[FloatBlock] > 0
    have_complex = counts[ComplexBlock] > 0
    have_dt64 = counts[DatetimeBlock] > 0
    have_numeric = have_float or have_complex or have_int

    if have_object or (have_bool and have_numeric) or (have_numeric and have_dt64):
        return np.dtype(object)
    elif have_bool:
        return np.dtype(bool)
    elif have_int and not have_float and not have_complex:
        return np.dtype("i8")
    elif have_dt64 and not have_float and not have_complex:
        return np.dtype("M8[ns]")
    elif have_complex:
        return np.dtype("c16")
    else:
        return np.dtype("f8")
# Buggy code
def _consolidate(blocks, items):
    """
    Merge blocks having same dtype
    """
    get_dtype = lambda x: x.dtype

    # sort by dtype
    grouper = itertools.groupby(sorted(blocks, key=get_dtype), lambda x: x.dtype)

    new_blocks = []
    for dtype, group_blocks in grouper:
        new_block = _merge_blocks(list(group_blocks), items)
        new_blocks.append(new_block)

    return new_blocks


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def _consolidate(blocks, items):
    """
    Merge blocks having same dtype
    """
    get_dtype = lambda x: x.dtype.name

    # sort by dtype
    grouper = itertools.groupby(sorted(blocks, key=get_dtype), lambda x: x.dtype)

    new_blocks = []
    for dtype, group_blocks in grouper:
        new_block = _merge_blocks(list(group_blocks), items)
        new_blocks.append(new_block)

    return new_blocks
# Buggy code
def _nanvar(values, axis=None, skipna=True, ddof=1):
    mask = isnull(values)

    if axis is not None:
        count = (values.shape[axis] - mask.sum(axis)).astype(float)
    else:
        count = float(values.size - mask.sum())

    if skipna:
        values = values.copy()
        np.putmask(values, mask, 0)

    X = _ensure_numeric(values.sum(axis))
    XX = _ensure_numeric((values**2).sum(axis))
    return (XX - X**2 / count) / (count - ddof)


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def _nanvar(values, axis=None, skipna=True, ddof=1):
    mask = isnull(values)

    if axis is not None:
        count = (values.shape[axis] - mask.sum(axis)).astype(float)
    else:
        count = float(values.size - mask.sum())

    if skipna:
        values = values.copy()
        np.putmask(values, mask, 0)

    X = _ensure_numeric(values.sum(axis))
    XX = _ensure_numeric((values**2).sum(axis))
    return np.fabs((XX - X**2 / count) / (count - ddof))
# Buggy code
def _nanmin(values, axis=None, skipna=True):
    mask = isnull(values)
    if skipna and not issubclass(values.dtype.type, np.integer):
        values = values.copy()
        np.putmask(values, mask, np.inf)
    # numpy 1.6.1 workaround in Python 3.x
    if values.dtype == np.object_ and sys.version_info[0] >= 3:  # pragma: no cover
        import __builtin__

        if values.ndim > 1:
            apply_ax = axis if axis is not None else 0
            result = np.apply_along_axis(__builtin__.min, apply_ax, values)
        else:
            result = __builtin__.min(values)
    else:
        result = values.min(axis)

    return _maybe_null_out(result, axis, mask)


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def _nanmin(values, axis=None, skipna=True):
    mask = isnull(values)
    if skipna and not issubclass(values.dtype.type, (np.integer, np.datetime64)):
        values = values.copy()
        np.putmask(values, mask, np.inf)
    # numpy 1.6.1 workaround in Python 3.x
    if values.dtype == np.object_ and sys.version_info[0] >= 3:  # pragma: no cover
        import __builtin__

        if values.ndim > 1:
            apply_ax = axis if axis is not None else 0
            result = np.apply_along_axis(__builtin__.min, apply_ax, values)
        else:
            result = __builtin__.min(values)
    else:
        result = values.min(axis)

    return _maybe_null_out(result, axis, mask)
# Buggy code
def _nanmax(values, axis=None, skipna=True):
    mask = isnull(values)
    if skipna and not issubclass(values.dtype.type, np.integer):
        values = values.copy()
        np.putmask(values, mask, -np.inf)
    # numpy 1.6.1 workaround in Python 3.x
    if values.dtype == np.object_ and sys.version_info[0] >= 3:  # pragma: no cover
        import __builtin__

        if values.ndim > 1:
            apply_ax = axis if axis is not None else 0
            result = np.apply_along_axis(__builtin__.max, apply_ax, values)
        else:
            result = __builtin__.max(values)
    else:
        result = values.max(axis)
    return _maybe_null_out(result, axis, mask)


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def _nanmax(values, axis=None, skipna=True):
    mask = isnull(values)
    if skipna and not issubclass(values.dtype.type, (np.integer, np.datetime64)):
        values = values.copy()
        np.putmask(values, mask, -np.inf)
    # numpy 1.6.1 workaround in Python 3.x
    if values.dtype == np.object_ and sys.version_info[0] >= 3:  # pragma: no cover
        import __builtin__

        if values.ndim > 1:
            apply_ax = axis if axis is not None else 0
            result = np.apply_along_axis(__builtin__.max, apply_ax, values)
        else:
            result = __builtin__.max(values)
    else:
        result = values.max(axis)
    return _maybe_null_out(result, axis, mask)
# Buggy code
def unique1d(values):
    """
    Hash table-based unique
    """
    if issubclass(values.dtype.type, np.floating):
        if values.dtype != np.float64:
            values = values.astype(np.float64)
        table = lib.Float64HashTable(len(values))
        uniques = np.array(table.unique(values), dtype=np.float64)
    elif issubclass(values.dtype.type, np.integer):
        if values.dtype != np.int64:
            values = values.astype(np.int64)
        table = lib.Int64HashTable(len(values))
        uniques = np.array(table.unique(values), dtype=np.int64)
    else:
        if not values.dtype == np.object_:
            values = values.astype(np.object_)
        table = lib.PyObjectHashTable(len(values))
        uniques = lib.list_to_object_array(table.unique(values))
    return uniques


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def unique1d(values):
    """
    Hash table-based unique
    """
    if np.issubdtype(values.dtype, np.floating):
        table = lib.Float64HashTable(len(values))
        uniques = np.array(table.unique(com._ensure_float64(values)), dtype=np.float64)
    elif np.issubdtype(values.dtype, np.datetime64):
        table = lib.Int64HashTable(len(values))
        uniques = np.array(table.unique(com._ensure_int64(values)), dtype=np.int64)
        uniques = uniques.view("M8[ns]")
    elif np.issubdtype(values.dtype, np.integer):
        table = lib.Int64HashTable(len(values))
        uniques = np.array(table.unique(com._ensure_int64(values)), dtype=np.int64)
    else:
        table = lib.PyObjectHashTable(len(values))
        uniques = table.unique(com._ensure_object(values))
        uniques = lib.list_to_object_array(uniques)
    return uniques
# Buggy code
def swapaxes(self, axis1="major", axis2="minor"):
    """
    Interchange axes and swap values axes appropriately

    Returns
    -------
    y : Panel (new object)
    """
    i = self._get_axis_number(axis1)
    j = self._get_axis_number(axis2)

    if i == j:
        raise ValueError("Cannot specify the same axis")

    mapping = {i: j, j: i}

    new_axes = (self._get_axis(mapping.get(k, k)) for k in range(3))
    new_values = self.values.swapaxes(i, j).copy()

    return self._constructor(new_values, *new_axes)


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def swapaxes(self, axis1="major", axis2="minor", copy=True):
    """
    Interchange axes and swap values axes appropriately

    Returns
    -------
    y : Panel (new object)
    """
    i = self._get_axis_number(axis1)
    j = self._get_axis_number(axis2)

    if i == j:
        raise ValueError("Cannot specify the same axis")

    mapping = {i: j, j: i}

    new_axes = (self._get_axis(mapping.get(k, k)) for k in range(3))
    new_values = self.values.swapaxes(i, j)
    if copy:
        new_values = new_values.copy()

    return self._constructor(new_values, *new_axes)
# Buggy code
def _extract_axis(data, axis=0, intersect=False):
    from pandas.core.index import _union_indexes

    if len(data) == 0:
        index = Index([])
    elif len(data) > 0:
        raw_lengths = []
        indexes = []

        have_raw_arrays = False
        have_frames = False

        for v in data.values():
            if isinstance(v, DataFrame):
                have_frames = True
                indexes.append(v._get_axis(axis))
            else:
                have_raw_arrays = True
                raw_lengths.append(v.shape[axis])

        if have_frames:
            index = _get_combined_index(indexes, intersect=intersect)

        if have_raw_arrays:
            lengths = list(set(raw_lengths))
            if len(lengths) > 1:
                raise ValueError("ndarrays must match shape on axis %d" % axis)

            if have_frames:
                assert lengths[0] == len(index)
            else:
                index = Index(np.arange(lengths[0]))

    return _ensure_index(index)


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def _extract_axis(data, axis=0, intersect=False):
    if len(data) == 0:
        index = Index([])
    elif len(data) > 0:
        raw_lengths = []
        indexes = []

        have_raw_arrays = False
        have_frames = False

        for v in data.values():
            if isinstance(v, DataFrame):
                have_frames = True
                indexes.append(v._get_axis(axis))
            else:
                have_raw_arrays = True
                raw_lengths.append(v.shape[axis])

        if have_frames:
            index = _get_combined_index(indexes, intersect=intersect)

        if have_raw_arrays:
            lengths = list(set(raw_lengths))
            if len(lengths) > 1:
                raise ValueError("ndarrays must match shape on axis %d" % axis)

            if have_frames:
                assert lengths[0] == len(index)
            else:
                index = Index(np.arange(lengths[0]))

    return _ensure_index(index)
# Buggy code
def get_new_values(self):
    return self._reshape_values(self.values)


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def get_new_values(self):
    values = self.values
    # place the values
    length, width = self.full_shape
    stride = values.shape[1]
    result_width = width * stride

    new_values = np.empty((length, result_width), dtype=values.dtype)
    new_mask = np.zeros((length, result_width), dtype=bool)

    if issubclass(values.dtype.type, np.integer):
        new_values = new_values.astype(float)

    new_values.fill(np.nan)

    # is there a simpler / faster way of doing this?
    for i in xrange(values.shape[1]):
        chunk = new_values[:, i * width : (i + 1) * width]
        mask_chunk = new_mask[:, i * width : (i + 1) * width]

        chunk.flat[self.mask] = self.sorted_values[:, i]
        mask_chunk.flat[self.mask] = True

    new_values = new_values.take(self.unique_groups, axis=0)
    return new_values, new_mask
# Buggy code
def unstack(obj, level):
    if isinstance(obj, DataFrame):
        if isinstance(obj.index, MultiIndex):
            return _unstack_frame(obj, level)
        else:
            return obj.T.stack(dropna=False)
    else:
        unstacker = _Unstacker(obj.values, obj.index, level=level)
        return unstacker.get_result()


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def unstack(obj, level):
    if isinstance(level, (tuple, list)):
        return _unstack_multiple(obj, level)

    if isinstance(obj, DataFrame):
        if isinstance(obj.index, MultiIndex):
            return _unstack_frame(obj, level)
        else:
            return obj.T.stack(dropna=False)
    else:
        unstacker = _Unstacker(obj.values, obj.index, level=level)
        return unstacker.get_result()
# Buggy code
def _get_val_at(self, loc):
    n = len(self)
    if loc < 0:
        loc += n

    if loc >= len(self) or loc < 0:
        raise Exception("Out of bounds access")

    sp_loc = self.sp_index.lookup(loc)
    if sp_loc == -1:
        return self.fill_value
    else:
        return _gin.get_value_at(self, sp_loc)


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def _get_val_at(self, loc):
    n = len(self)
    if loc < 0:
        loc += n

    if loc >= len(self) or loc < 0:
        raise Exception("Out of bounds access")

    sp_loc = self.sp_index.lookup(loc)
    if sp_loc == -1:
        return self.fill_value
    else:
        return lib.get_value_at(self, sp_loc)
# Buggy code
def __getitem__(self, item):
    """
    Retrieve column or slice from DataFrame
    """
    try:
        # unsure about how kludgy this is
        s = self._series[item]
        s.name = item
        return s
    except (TypeError, KeyError):
        if isinstance(item, slice):
            dateRange = self.index[item]
            return self.reindex(dateRange)

        elif isinstance(item, np.ndarray):
            if len(item) != len(self.index):
                raise Exception(
                    "Item wrong length %d instead of %d!" % (len(item), len(self.index))
                )
            newIndex = self.index[item]
            return self.reindex(newIndex)
        else:  # pragma: no cover
            raise


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def __getitem__(self, item):
    """
    Retrieve column or slice from DataFrame
    """
    try:
        # unsure about how kludgy this is
        s = self._series[item]
        s.name = item
        return s
    except (TypeError, KeyError):
        if isinstance(item, slice):
            date_rng = self.index[item]
            return self.reindex(date_rng)

        elif isinstance(item, np.ndarray):
            if len(item) != len(self.index):
                raise Exception(
                    "Item wrong length %d instead of %d!" % (len(item), len(self.index))
                )
            newIndex = self.index[item]
            return self.reindex(newIndex)
        else:  # pragma: no cover
            raise
# Buggy code
def _combine_frame(self, other, func, fill_value=None, level=None):
    this, other = self.align(other, join="outer", level=level, copy=False)
    new_index, new_columns = this.index, this.columns

    if level is not None:
        raise NotImplementedError

    if not self and not other:
        return SparseDataFrame(index=new_index)

    new_data = {}
    if fill_value is not None:
        # TODO: be a bit more intelligent here
        for col in new_columns:
            if col in this and col in other:
                dleft = this[col].to_dense()
                dright = other[col].to_dense()
                result = dleft._binop(dright, func, fill_value=fill_value)
                result = result.to_sparse(fill_value=this[col].fill_value)
                new_data[col] = result
    else:
        for col in new_columns:
            if col in this and col in other:
                new_data[col] = func(this[col], other[col])

    return self._constructor(data=new_data, index=new_index, columns=new_columns)


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def _combine_frame(self, other, func, fill_value=None, level=None):
    this, other = self.align(other, join="outer", level=level, copy=False)
    new_index, new_columns = this.index, this.columns

    if level is not None:
        raise NotImplementedError

    if self.empty and other.empty:
        return SparseDataFrame(index=new_index)

    new_data = {}
    if fill_value is not None:
        # TODO: be a bit more intelligent here
        for col in new_columns:
            if col in this and col in other:
                dleft = this[col].to_dense()
                dright = other[col].to_dense()
                result = dleft._binop(dright, func, fill_value=fill_value)
                result = result.to_sparse(fill_value=this[col].fill_value)
                new_data[col] = result
    else:
        for col in new_columns:
            if col in this and col in other:
                new_data[col] = func(this[col], other[col])

    return self._constructor(data=new_data, index=new_index, columns=new_columns)
# Buggy code
def _reindex_index(self, index, method, copy, level, fill_value=np.nan):
    if level is not None:
        raise Exception("Reindex by level not supported for sparse")

    if self.index.equals(index):
        if copy:
            return self.copy()
        else:
            return self

    if len(self.index) == 0:
        return SparseDataFrame(index=index, columns=self.columns)

    indexer = self.index.get_indexer(index, method)
    mask = indexer == -1
    need_mask = mask.any()

    new_series = {}
    for col, series in self.iteritems():
        values = series.values
        new = values.take(indexer)

        if need_mask:
            np.putmask(new, mask, fill_value)

        new_series[col] = new

    return SparseDataFrame(
        new_series,
        index=index,
        columns=self.columns,
        default_fill_value=self.default_fill_value,
    )


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def _reindex_index(self, index, method, copy, level, fill_value=np.nan, limit=None):
    if level is not None:
        raise Exception("Reindex by level not supported for sparse")

    if self.index.equals(index):
        if copy:
            return self.copy()
        else:
            return self

    if len(self.index) == 0:
        return SparseDataFrame(index=index, columns=self.columns)

    indexer = self.index.get_indexer(index, method, limit=limit)
    indexer = com._ensure_platform_int(indexer)
    mask = indexer == -1
    need_mask = mask.any()

    new_series = {}
    for col, series in self.iteritems():
        values = series.values
        new = values.take(indexer)

        if need_mask:
            np.putmask(new, mask, fill_value)

        new_series[col] = new

    return SparseDataFrame(
        new_series,
        index=index,
        columns=self.columns,
        default_fill_value=self.default_fill_value,
    )
# Buggy code
def _reindex_columns(self, columns, copy, level, fill_value):
    if level is not None:
        raise Exception("Reindex by level not supported for sparse")

    if com.notnull(fill_value):
        raise NotImplementedError

    # TODO: fill value handling
    sdict = dict((k, v) for k, v in self.iteritems() if k in columns)
    return SparseDataFrame(
        sdict,
        index=self.index,
        columns=columns,
        default_fill_value=self.default_fill_value,
    )


# Traceback (ValueError)
In [17]: date_range(datetime.datetime.today(), periods=10, freq='2h20m')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/chang/Dropbox/git/pandas/<ipython-input-17-ff4e03382573> in <module>()
----> 1 date_range(datetime.datetime.today(), periods=10, freq='2h20m')

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in date_range(start, end, periods, freq, tz, normalize)
1209     """
1210     return DatetimeIndex(start=start, end=end, periods=periods,
-> 1211                          freq=freq, tz=tz, normalize=normalize)
1212
1213

/home/chang/Dropbox/git/pandas/pandas/tseries/index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, **kwds)
202
203         if data is None and offset is None:
--> 204             raise ValueError("Must provide freq argument if no data is "
205                              "supplied")
206

ValueError: Must provide freq argument if no data is supplied

# Fixed code
def _reindex_columns(self, columns, copy, level, fill_value, limit=None):
    if level is not None:
        raise Exception("Reindex by level not supported for sparse")

    if com.notnull(fill_value):
        raise NotImplementedError

    if limit:
        raise NotImplementedError

    # TODO: fill value handling
    sdict = dict((k, v) for k, v in self.iteritems() if k in columns)
    return SparseDataFrame(
        sdict,
        index=self.index,
        columns=columns,
        default_fill_value=self.default_fill_value,
    )