示例#1
0
def test_isnull():
    assert not isnull(1.)
    assert isnull(None)
    assert isnull(np.NaN)
    assert not isnull(np.inf)
    assert not isnull(-np.inf)

    # series
    for s in [tm.makeFloatSeries(),tm.makeStringSeries(),
              tm.makeObjectSeries(),tm.makeTimeSeries(),tm.makePeriodSeries()]:
        assert(isinstance(isnull(s), Series))

    # frame
    for df in [tm.makeTimeDataFrame(),tm.makePeriodFrame(),tm.makeMixedDataFrame()]:
        result = isnull(df)
        expected = df.apply(isnull)
        tm.assert_frame_equal(result, expected)

    # panel
    for p in [ tm.makePanel(), tm.makePeriodPanel(), tm.add_nans(tm.makePanel()) ]:
        result = isnull(p)
        expected = p.apply(isnull)
        tm.assert_panel_equal(result, expected)

    # panel 4d
    for p in [ tm.makePanel4D(), tm.add_nans_panel4d(tm.makePanel4D()) ]:
        result = isnull(p)
        expected = p.apply(isnull)
        tm.assert_panel4d_equal(result, expected)
示例#2
0
def test_isnull():
    assert not isnull(1.)
    assert isnull(None)
    assert isnull(np.NaN)
    assert not isnull(np.inf)
    assert not isnull(-np.inf)

    # series
    for s in [tm.makeFloatSeries(), tm.makeStringSeries(),
              tm.makeObjectSeries(), tm.makeTimeSeries(),
              tm.makePeriodSeries()]:
        assert (isinstance(isnull(s), Series))

    # frame
    for df in [tm.makeTimeDataFrame(), tm.makePeriodFrame(),
               tm.makeMixedDataFrame()]:
        result = isnull(df)
        expected = df.apply(isnull)
        tm.assert_frame_equal(result, expected)

    # panel
    for p in [tm.makePanel(), tm.makePeriodPanel(), tm.add_nans(tm.makePanel())
              ]:
        result = isnull(p)
        expected = p.apply(isnull)
        tm.assert_panel_equal(result, expected)

    # panel 4d
    for p in [tm.makePanel4D(), tm.add_nans_panel4d(tm.makePanel4D())]:
        result = isnull(p)
        expected = p.apply(isnull)
        tm.assert_panel4d_equal(result, expected)
示例#3
0
    def test_isnull(self):
        self.assertFalse(isnull(1.))
        self.assertTrue(isnull(None))
        self.assertTrue(isnull(np.NaN))
        self.assertTrue(float('nan'))
        self.assertFalse(isnull(np.inf))
        self.assertFalse(isnull(-np.inf))

        # series
        for s in [tm.makeFloatSeries(), tm.makeStringSeries(),
                  tm.makeObjectSeries(), tm.makeTimeSeries(),
                  tm.makePeriodSeries()]:
            self.assertIsInstance(isnull(s), Series)

        # frame
        for df in [tm.makeTimeDataFrame(), tm.makePeriodFrame(),
                   tm.makeMixedDataFrame()]:
            result = isnull(df)
            expected = df.apply(isnull)
            tm.assert_frame_equal(result, expected)

        # panel
        with catch_warnings(record=True):
            for p in [tm.makePanel(), tm.makePeriodPanel(),
                      tm.add_nans(tm.makePanel())]:
                result = isnull(p)
                expected = p.apply(isnull)
                tm.assert_panel_equal(result, expected)

        # panel 4d
        with catch_warnings(record=True):
            for p in [tm.makePanel4D(), tm.add_nans_panel4d(tm.makePanel4D())]:
                result = isnull(p)
                expected = p.apply(isnull)
                tm.assert_panel4d_equal(result, expected)
示例#4
0
    def test_isnull(self):
        self.assertFalse(isnull(1.))
        self.assertTrue(isnull(None))
        self.assertTrue(isnull(np.NaN))
        self.assertTrue(float('nan'))
        self.assertFalse(isnull(np.inf))
        self.assertFalse(isnull(-np.inf))

        # series
        for s in [tm.makeFloatSeries(), tm.makeStringSeries(),
                  tm.makeObjectSeries(), tm.makeTimeSeries(),
                  tm.makePeriodSeries()]:
            assert isinstance(isnull(s), Series)

        # frame
        for df in [tm.makeTimeDataFrame(), tm.makePeriodFrame(),
                   tm.makeMixedDataFrame()]:
            result = isnull(df)
            expected = df.apply(isnull)
            tm.assert_frame_equal(result, expected)

        # panel
        with catch_warnings(record=True):
            for p in [tm.makePanel(), tm.makePeriodPanel(),
                      tm.add_nans(tm.makePanel())]:
                result = isnull(p)
                expected = p.apply(isnull)
                tm.assert_panel_equal(result, expected)

        # panel 4d
        with catch_warnings(record=True):
            for p in [tm.makePanel4D(), tm.add_nans_panel4d(tm.makePanel4D())]:
                result = isnull(p)
                expected = p.apply(isnull)
                tm.assert_panel4d_equal(result, expected)
示例#5
0
    def test_isna_isnull(self, isna_f):
        assert not isna_f(1.)
        assert isna_f(None)
        assert isna_f(np.NaN)
        assert float('nan')
        assert not isna_f(np.inf)
        assert not isna_f(-np.inf)

        # series
        for s in [
                tm.makeFloatSeries(),
                tm.makeStringSeries(),
                tm.makeObjectSeries(),
                tm.makeTimeSeries(),
                tm.makePeriodSeries()
        ]:
            assert isinstance(isna_f(s), Series)

        # frame
        for df in [
                tm.makeTimeDataFrame(),
                tm.makePeriodFrame(),
                tm.makeMixedDataFrame()
        ]:
            result = isna_f(df)
            expected = df.apply(isna_f)
            tm.assert_frame_equal(result, expected)

        # panel
        with catch_warnings(record=True):
            for p in [
                    tm.makePanel(),
                    tm.makePeriodPanel(),
                    tm.add_nans(tm.makePanel())
            ]:
                result = isna_f(p)
                expected = p.apply(isna_f)
                tm.assert_panel_equal(result, expected)

        # panel 4d
        with catch_warnings(record=True):
            for p in [tm.makePanel4D(), tm.add_nans_panel4d(tm.makePanel4D())]:
                result = isna_f(p)
                expected = p.apply(isna_f)
                tm.assert_panel4d_equal(result, expected)