<jupyter_start><jupyter_text>Method 1 By using transform maxk and feed that back to the original dataframe to subset the matching maximum values<jupyter_code>#Only lc > 100
dfpileutil = dfpileutil[dfpileutil['lc'] > 100]


# Group by the pile number, and find the maximum utilisation
maxurlist = dfpileutil[['pile', 'UR']].groupby(by=['pile']).transform(max)
dfpileutil_maxur_perpile = dfpileutil[dfpileutil['UR'] == maxurlist['UR']].sort_values(by='pile', ascending=True)
print(dfpileutil_maxur_perpile)<jupyter_output>lc  pile  node        z  sigma  node_sect   z_sect     UR  ax_force  \
3088  194     1     1  188.524   92.7          1  188.524  0.294   29920.0   
3153  198     2     1  188.524   53.4          1  188.524  0.170   14200.0   
2562  161     3     1  188.524   50.8          1  188.524  0.161   12690.0   
3154  198     3     1  188.524   50.7          1  188.524  0.161   14820.0   
3042  191     3     1  188.524   50.7          1  188.524  0.161   14850.0   
2563  161     4     1  188.524   57.7          1  188.524  0.183   18390.0   
3155  198     4     1  188.524   57.6          1  188.524  0.183   20750.0   
3043  191     4     1  188.524   57.6          1  188.524  0.183   20860.0   
3060  192     5     1  188.524   72.5          1  188.524  0.230   27690.0   
3061  192     6     1  188.524   64.9          1  188.524  0.206   20580.0   
3062  192     7     1  188.524   66.9          1  188.524  0.212   20230.0   
3063  192     8     1  188.524   77.7          1  188.524  0.247[...]<jupyter_text>However, as there are more than one with matching max UR values for each pile, filter it again by using maximum ax_force<jupyter_code>dfpileutil_maxur_perpile_maxax =  dfpileutil_maxur_perpile.sort_values(by='ax_force', ascending=False).drop_duplicates(subset=['pile'], keep='first')
print(dfpileutil_maxur_perpile_maxax.sort_values(by='pile'))<jupyter_output>lc  pile  node        z  sigma  node_sect   z_sect     UR  ax_force  \
3088  194     1     1  188.524   92.7          1  188.524  0.294   29920.0   
3153  198     2     1  188.524   53.4          1  188.524  0.170   14200.0   
3042  191     3     1  188.524   50.7          1  188.524  0.161   14850.0   
3043  191     4     1  188.524   57.6          1  188.524  0.183   20860.0   
3060  192     5     1  188.524   72.5          1  188.524  0.230   27690.0   
3061  192     6     1  188.524   64.9          1  188.524  0.206   20580.0   
3062  192     7     1  188.524   66.9          1  188.524  0.212   20230.0   
3063  192     8     1  188.524   77.7          1  188.524  0.247   26930.0   
3096  194     9     1  188.524   78.8          1  188.524  0.250   22750.0   
3097  194    10     1  188.524   73.1          1  188.524  0.232   23410.0   
3114  195    11     1  188.524   80.3          1  188.524  0.255   31370.0   
2571  161    12     1  188.524   66.9          1  188.524  0.212[...]
{'fraction_non_alphanumeric': 0.07993079584775087, 'fraction_numerical': 0.28996539792387543, 'mean_word_length': 1.4836769759450172, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '442746', 'license': 'MIT', 'n_tokens_mistral': 1598, 'n_tokens_neox': 1138, 'n_words': 322, 'path': 'test_getpileutil.ipynb', 'repo_name': 'aryoseto/sesamutil', 'size': '2890'}