✔ Pandas solution clearly explained with comments.
Intuition\n Describe your first thoughts on how to solve this problem. \nGet necessary information from different tables into a single table. Find out people wh
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nGet necessary information from different tables into a single table. Find out people who are related to RED. Consequently, you know who are not related to RED.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Firstly join `sales_person` and `orders` dataframe. `outer` join because we don\'t want information loss in any of the two dataframes.\n2. Perform a second (final) join with `company` dataframe. `left` because we don\'t want redundant information from company.\n3. Filter sales persons involved in sales related to RED.\n4. To obtain people who are not related to RED, perform an outer join between `sales_person[[name]]` and `red` dataframes with indicator flag set to True.\n5. Return the name of the people with "left_only" indicator in the "_merge" column of `non_red` dataframe.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nimport pandas as pd\n\ndef sales_person(sales_person: pd.DataFrame, company: pd.DataFrame, orders: pd.DataFrame) -> pd.DataFrame:\n    # Firstly join `sales_person` and `orders` dataframe. `outer` join because we don\'t want information loss in any of the two dataframes.\n    intermediate_merge = sales_person.merge(right=orders, how="outer", on="sales_id")\n\n    # Perform a second (final) join with `company` dataframe. `left` because we don\'t want redundant information from company.\n    final_merge = intermediate_merge.merge(right=company, how="left", on="com_id")\n\n    # Filter sales persons involved in sales related to RED.\n    red= final_merge[final_merge["name_y"] == "RED"][["name_x"]]\n\n    # To obtain people who are not related to RED, perform an outer join between `sales_person[[name]]` and `red` dataframes with indicator flag set to True. \n    non_red = sales_person[["name"]].merge(right=red, how="outer", left_on="name", right_on="name_x", indicator=True)\n\n    # Return the name of the people with "left_only" indicator in the "_merge" column of `non_red` dataframe.\n    return non_red[non_red["_merge"] == "left_only"][["name"]]\n```
['Pandas']