def _get_jgroup(grouped_data):
    """Get the JVM object that backs this grouped data, taking into account the different
    spark versions."""
    d = dir(grouped_data)
    if '_jdf' in d:
        return grouped_data._jdf
    if '_jgd' in d:
        return grouped_data._jgd
    raise ValueError('Could not find a dataframe for {}. All methods: {}'.format(grouped_data, d))