test_resample.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码
def test_fails_on_no_datetime_index(self):
        index_names = ('Int64Index', 'Index', 'Float64Index', 'MultiIndex')
        index_funcs = (tm.makeIntIndex,
                       tm.makeUnicodeIndex, tm.makeFloatIndex,
                       lambda m: tm.makeCustomIndex(m, 2))
        n = 2
        for name, func in zip(index_names, index_funcs):
            index = func(n)
            df = DataFrame({'a': np.random.randn(n)}, index=index)
            with tm.assertRaisesRegexp(TypeError,
                                       "Only valid with DatetimeIndex, "
                                       "TimedeltaIndex or PeriodIndex, "
                                       "but got an instance of %r" % name):
                df.groupby(TimeGrouper('D'))

        # PeriodIndex gives a specific error message
        df = DataFrame({'a': np.random.randn(n)}, index=tm.makePeriodIndex(n))
        with tm.assertRaisesRegexp(TypeError,
                                   "axis must be a DatetimeIndex, but "
                                   "got an instance of 'PeriodIndex'"):
            df.groupby(TimeGrouper('D'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号