<jupyter_start><jupyter_text>Documentation and Testing  Example 1<jupyter_code>def remove_extremes(ls: list, key=None) -> list:
    """
    Remove the extreme elements of a list, i.e. minimum and maximum
    If list has less than three elements the original list will be returned
    A function can be provided for custom order
    
    Parameter:
        ls:  list of elements, elements need to be ordered
        key: function to customize sort order
        
    Returns:
        res: list of elements without the extremes
    """
    if len(ls) < 3:
        return sorted(ls, key=key)
    ls_sorted = sorted(ls, key=key)
    res = ls_sorted[1:-1]
    return res›<jupyter_output><empty_output><jupyter_text>Show documentation![](help_remove_extremes.png)<jupyter_code>help(remove_extremes)<jupyter_output>Help on function remove_extremes in module __main__:

remove_extremes(ls: list, key=None) -> list
    Remove the extreme elements of a list, i.e. minimum and maximum
    If list has less than three elements the original list will be returned
    A function can be provided for custom order
    
    Parameter:
        ls:  list of elements, elements need to be ordered
        key: function to customize sort order
        
    Returns:
        res: list of elements without the extremes<jupyter_text>TestJust use the `assert` statement<jupyter_code>x1 = [13, 345, 7, 89, 2, 0, 34, 103]
x2 = [78, 67]
x3 = ['Hello', 'Zoo', 'Zeppelin', 'Albert', 'Bravo', 'Gustave']
x4 = ['zz', 'zzzzzz', 'z', 'zzz', 'zzzz']

assert remove_extremes(x1) == [2, 7, 13, 34, 89, 103], 'Test 1: "List of integers" failed'
assert remove_extremes(x2) == [67, 78], 'Test 2: "Only two elements" failed'
assert remove_extremes(x3) == ['Bravo', 'Gustave', 'Hello', 'Zeppelin'], 'Test 3: "List of strings" failed'
assert remove_extremes(x4, key=lambda s: len(s)) == ['zz', 'zzz', 'zzzz']
# shorter version of Test 4
assert remove_extremes(x4, key=len) == ['zz', 'zzz', 'zzzz']
! ls ../data

import pandas as pd

employees_df = pd.read_csv('../data/employees.csv')
print(f"Number of records: {employees_df.shape[0]:,}")
display(employees_df.dtypes)
display(employees_df.head())
offices_df = pd.read_csv('../data/offices.csv')
print(f"Number of records: {offices_df.shape[0]:,}")
display(offices_df.dtypes)
display(offices_df.head())<jupyter_output>Number of records: 7<jupyter_text>Let's join the tables<jupyter_code>joined_df = employees_df.join(offices_df.set_index('officeCode'), on='officeCode')
joined_df.head(3).T<jupyter_output><empty_output><jupyter_text>Let's assume every employee is assigned to exactly one office. When we join the tables `employees_df` and `offices_df` we should still have the same number of rows.<jupyter_code>assert employees_df.shape[0] == joined_df.shape[0], "Mismatched number of rows"
print(employees_df.dtypes)<jupyter_output>employeeNumber      int64
lastName           object
firstName          object
extension          object
email              object
officeCode          int64
reportsTo         float64
jobTitle           object
dtype: object
{'fraction_non_alphanumeric': 0.11499509964064031, 'fraction_numerical': 0.020581509310682783, 'mean_word_length': 4.1289782244556115, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '640787', 'license': 'MIT', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1009, 'n_words': 309, 'path': '3_Documentation_Testing/Documentation_Testing_Example.ipynb', 'repo_name': 'kingmolnar/Data-Science-Best-Practices', 'size': '3061'}