```Python
import pandas as pd
df = pd.DataFrame({
'group': ['A', 'A', 'B', 'B', 'C', 'C'],
'count': [3, 5, 7, 2, 8, 1]
})
```
Group by 'group' columns and identify the max. 'count' value within each group:
```Python
max_counts = df.groupby('group')['count'].max()
```
Filter the DataFrame to keep only rows with max count value within each group
by identifying any rows that have the max. count for each group:
```Python
result = df[df.apply(
lambda x: x['count'] == max_counts.loc[x['group']],
axis="columns"
)]
```
```
max_counts.loc[x['group']]
```
finds the max. count for the given group.