def extract_dict_key(dataframe, column, key, new_column=None, separator='.'):
    """
        Extract values of ``key`` into ``new_column``. If key is missing, ``None`` is added to
        the column.

        .. code-block:: python

            >>> df = DataFrame({
            ...    'trial_num': [1, 2, 1, 2],
            ...    'subject': [1, 1, 2, 2],
            ...    'samples': [
            ...        {'A': 1, 'B': 2, 'C': None},
            ...        {'A': 3, 'B': 4, 'C': 5},
            ...        {'A': 6, 'B': 7, 'C': None},
            ...        None,
            ...    ]
            ...})
            >>>df.pipe(extract_dict_key, 'samples', key='A')
                trial_num  subject  samples.A                      samples
            0           1        1          1  {'A': 1, 'B': 2, 'C': None}
            1           2        1          3     {'A': 3, 'B': 4, 'C': 5}
            2           1        2          6  {'A': 6, 'B': 7, 'C': None}
            3           2        2        NaN                          NaN

        :param dataframe: The DataFrame object to work on.
        :type dataframe: :class:`DataFrame <pandas.DataFrame>`
        :param str column: The name of the column which should be extracted.
        :param str key: Key that should be extracted.
        :param str new_column: Name of the new column. By default, ``column`` will be applied as
                               prefix to ``key``.
        :param str separator: The separator between ``column`` and ``key`` if ``new_column`` is
                              not specified.

        :returns: The extracted DataFrame
        :rtype: :class:`DataFrame <pandas.DataFrame>`
    """
    new_column = new_column or '{}{}{}'.format(column, separator, key) if new_column != "" else key
    dataframe.loc[:, new_column] = dataframe[column].apply(
        lambda x: x.get(key) if isinstance(x, dict) else x
    ).rename(new_column)
    return dataframe