def test_none_missing_raises(): df = pd.DataFrame(np.random.randn(5, 3)) df.iloc[0, 0] = np.nan with pytest.raises(AssertionError): ck.none_missing(df) with pytest.raises(AssertionError): dc.none_missing()(_add_one)(df)
def test_none_missing(): df = pd.DataFrame(np.random.randn(5, 3)) result = ck.none_missing(df) tm.assert_frame_equal(df, result) result = dc.none_missing()(_add_one)(df) tm.assert_frame_equal(result, df + 1)
'two': [i**2 for i in range(5)] }, index=ind) adf.ix[4, 'two'] = pd.np.NaN """ one two 2010-12-31 0 0 2011-12-31 1 1 2012-12-31 2 4 2013-12-31 3 9 2014-12-31 4 NaN """ # Basic call... try: none_missing(adf) except AssertionError: print "Some values are missing!" # Using arguments explicitly try: none_missing(adf, columns='one') print "No problem here!" except: pass # Or implicitly using arguments... try: none_missing(adf, 'two') print "Shouldn't see this!" except:
ind = pd.date_range('2010', '2015', freq='A') adf = pd.DataFrame({'one' : range(5), 'two' : [ i ** 2 for i in range(5)]}, index=ind) adf.ix[4,'two'] = pd.np.NaN """ one two 2010-12-31 0 0 2011-12-31 1 1 2012-12-31 2 4 2013-12-31 3 9 2014-12-31 4 NaN """ # Basic call... try: none_missing(adf) except AssertionError: print "Some values are missing!" # Using arguments explicitly try: none_missing(adf, columns='one') print "No problem here!" except: pass # Or implicitly using arguments... try: none_missing(adf, 'two') print "Shouldn't see this!" except: