jhylands

Example driven function finder

May 3rd, 2022
1,101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. def test_df_shape():
  2.     df = pd.DataFrame({"a": [1, 2, 3]})
  3.     df2 = pd.DataFrame({"a": [4, 5, 6]})
  4.  
  5.     def object_generator():
  6.         return deepcopy([df, df2])
  7.  
  8.     def criteria(output):
  9.         return len(output) == 6
  10.  
  11.     functions = [
  12.         getattr(pd, attr) for attr in dir(pd) if isinstance(getattr(pd, attr), Callable)
  13.     ]
  14.     path = find_function_match(object_generator, criteria, functions)
  15.     assert path.__name__ == "concat"
  16.  
Advertisement
Add Comment
Please, Sign In to add comment