<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Results
Notice, the results are incomplete (probably not even optimal)
the results are missing all the combined permutations, so only groups that are formed from mineral names and combinations of 4 (+some 5) unique letters are compared here
Step1:  Max only
Step2:  Max and friends
<ASSISTANT_TASK:>
Python Code:
max_group_for_size = df_subsets.groupby(by='len').apply(lambda x: pd.Series({'group_len' : x['set_len'].max(),
                                                                             'group' : x.loc[x['set_len'].argmax(), 'name'],
                                                                             'list_group' : x.loc[x['set_len'].argmax(), 'subset_groups'],
                                                                             'relative_len' : x['set_len'].max()/len(x.loc[x['set_len'].argmax(), 'name'])
                                                                            })).reset_index(drop=False)
max_group_for_size['group_and_len'] = max_group_for_size.apply(lambda  x: "{} - {}".format(x['group'], x['len']), axis=1)
max_group_for_size
max_group_len = {}
for index, row in max_group_for_size.iterrows():
    max_group_len[row['len']] = row['list_group']
    if row['group_len'] < 100:
        print()
        print(row['group'])
        print(row['list_group'])
max_group_for_size_and_friends = df_subsets.groupby(by='len').apply(lambda x: pd.DataFrame({'group_len' : x.loc[x['set_len'] == x['set_len'].max(), 
                                                                                                          'set_len'],
                                                                                            'group' : x.loc[x['set_len'] == x['set_len'].max(),
                                                                                                            'name'],
                                                                                            'list_group' : x.loc[x['set_len'] == x['set_len'].max(), 
                                                                                                                 'subset_groups'],
                                                                                            'relative_len' : x.loc[x['set_len'] == x['set_len'].max(),
                                                                                                                                   'set_len'] / \
                                                                                                             x.loc[x['set_len'] == x['set_len'].max(),
                                                                                                                   'name'].apply(len),
                                                                                           })).reset_index(drop=False)
max_group_for_size_and_friends.drop(['level_1'], axis=1, inplace=True)
max_group_for_size_and_friends['group_and_len'] = max_group_for_size_and_friends.apply(lambda  x: "{} - {}".format(x['group'], x['len']), axis=1)
max_group_for_size_and_friends
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('ggplot')
Explanation: Results
Notice, the results are incomplete (probably not even optimal)
the results are missing all the combined permutations, so only groups that are formed from mineral names and combinations of 4 (+some 5) unique letters are compared here
End of explanation
fig = plt.figure(figsize=(14,5))
ax = plt.subplot(121)
ax = max_group_for_size.plot.bar(x='group_and_len', y='group_len', width=0.9, ax=ax)
ax.set_yscale('log')
ax = plt.subplot(122)
ax = max_group_for_size.plot.bar(x='group_and_len', y='relative_len', width=0.9, ax=ax, color='royalblue')
ax.set_yscale('log')
Explanation: Max only
End of explanation
fig = plt.figure(figsize=(14,5))
ax = plt.subplot(121)
ax = max_group_for_size_and_friends.plot.bar(x='group_and_len', y='group_len', width=0.9, ax=ax)
ax.set_yscale('log')
ax = plt.subplot(122)
ax = max_group_for_size_and_friends.plot.bar(x='group_and_len', y='relative_len', width=0.9, ax=ax, color='royalblue')
ax.set_yscale('log')
Explanation: Max and friends
End of explanation
<END_TASK>