test_datetimelike.py 文件源码

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

项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码
def test_fillna_period(self):
        # GH 11343
        idx = pd.PeriodIndex(
            ['2011-01-01 09:00', pd.NaT, '2011-01-01 11:00'], freq='H')

        exp = pd.PeriodIndex(
            ['2011-01-01 09:00', '2011-01-01 10:00', '2011-01-01 11:00'
             ], freq='H')
        self.assert_index_equal(
            idx.fillna(pd.Period('2011-01-01 10:00', freq='H')), exp)

        exp = pd.Index([pd.Period('2011-01-01 09:00', freq='H'), 'x',
                        pd.Period('2011-01-01 11:00', freq='H')], dtype=object)
        self.assert_index_equal(idx.fillna('x'), exp)

        with tm.assertRaisesRegexp(
                ValueError,
                'Input has different freq=D from PeriodIndex\\(freq=H\\)'):
            idx.fillna(pd.Period('2011-01-01', freq='D'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号