Example #1
0
 def test_basic(self, simple_df):
     """ Ensure the functions are applied to the dataframe """
     df = simple_df
     td = np.timedelta64(1, "s")
     funcs = {"time": lambda x: x + td, "latitude": lambda x: x + 1}
     out = upd.apply_funcs_to_columns(simple_df, funcs)
     # a dataframe copy should have been returned
     assert out is not df
     # very the functions were applied
     assert (out["time"] == df["time"] + td).all()
     assert (out["latitude"] == df["latitude"] + 1).all()
Example #2
0
 def test_inplace(self, simple_df):
     """ Inplace should be, well, inplace. """
     funcs = {"latitude": lambda x: x + 1}
     out = upd.apply_funcs_to_columns(simple_df, funcs, inplace=True)
     assert out is simple_df
Example #3
0
 def test_skips_missing_column(self, simple_df):
     """ A function should not be called on a non-existent column. """
     funcs = {"bob": lambda x: x / 0}
     out = upd.apply_funcs_to_columns(simple_df, funcs)
     assert "bob" not in out.columns