def resample_data(df, method, variable, lat):
    """Resamples a pandas dataframe containing monthly averages of a climate
    variable.

    Parameters
    ----------
    df : Pandas DataFrame
        DataFrame containing the data to be resampled.
    method : String
        String describing which method to use for resampling.
    variable : String
        String describing what climatic variable the dataframe contains.
    lat : float
        Latitude of the gridpoint.

    Returns
    -------
    The resampled dataframe.
    """
    # Find first year of dataframe.
    first_year = str(df.index.year[0])
    # Specifying the month when seasons change.
    start_month = '-04'
    # Southern hemisphere winter/summer has to be reversed. Maybe there is a
    # prettier way?
    if lat < 0 and method == 'Summer':
        method = 'Winter'
    elif lat < 0 and method == 'Winter':
        method = 'Summer'
    # Dict of the different resampling methods.
    methods = {'Yearly': ['12M', '-01', 0, 1],
               'Summer': ['6M', start_month, 0, 2],
               'Winter': ['6M', start_month, 1, 2]}
    use_method = methods[method]
    # For precipitation monthly means should be summed.
    if variable == 'Precipitation':
        data = df[first_year+use_method[1]:].resample(use_method[0],
                                                      closed='left').sum()
    # For temperature an average should be calculated for the monthly means.
    else:
        data = df[first_year+use_method[1]:].resample(use_method[0],
                                                      closed='left').mean()
    return(data[use_method[2]::use_method[3]])